This script creates a temporary table named 'lead' containing character strings with varying indentations. It uses the LEFT function within a Data Step to left-align the text by removing initial spaces. The result is displayed using the PRINT procedure with specific formatting to visualize the strings before and after processing.
Data Analysis
Type : INTERNAL_CREATION
Data is generated directly in the code via the DATALINES statement.
1 Code Block
DATA STEP Data
Explanation : Creation of the 'lead' dataset and application of the LEFT function on the 'string' variable to create the 'left_string' variable without leading spaces.
Copied!
data lead;
input string $15.;
left_string = Left(string);
datalines;
ABC
XYZ
Ron Cody
;
1
DATA lead;
2
INPUT string $15.;
3
left_string = Left(string);
4
DATALINES;
5
ABC
6
XYZ
7
Ron Cody
8
;
2 Code Block
PROC PRINT
Explanation : Displaying data from the 'lead' table to compare the original and processed strings. Using the $quote17. format to visualize string boundaries.
Copied!
proc print data=lead noobs;
title"Left_funct";
Format string left_string $quote17.;
run;
1
PROC PRINTDATA=lead noobs;
2
title"Left_funct";
3
FORMAT string left_string $quote17.;
4
RUN;
This material is provided "as is" by We Are Cas. There are no warranties, expressed or implied, as to merchantability or fitness for a particular purpose regarding the materials or code contained herein. We Are Cas is not responsible for errors in this material as it now exists or will exist, nor does We Are Cas provide technical support for it.
SAS and all other SAS Institute Inc. product or service names are registered trademarks or trademarks of SAS Institute Inc. in the USA and other countries. ® indicates USA registration. WeAreCAS is an independent community site and is not affiliated with SAS Institute Inc.
This site uses technical and analytical cookies to improve your experience.
Read more.