Source data comes from the SASHELP library (sashelp.class). New datasets (myclass, myclass1, under13) are created and manipulated internally within the script.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates a new dataset called 'myclass'. It reads observations from the 'sashelp.class' dataset and adds a new variable 'heightcm' by multiplying the existing 'height' variable by 2. 'run;' terminates the DATA step.
Copied!
data myclass;
set sashelp.class;
heightcm=height*2;
run;
1
DATA myclass;
2
SET sashelp.class;
3
heightcm=height*2;
4
RUN;
2 Code Block
PROC PRINT
Explanation : This PROC PRINT step displays the contents of the 'myclass' dataset in the results window. It is a common procedure for quickly examining data.
Copied!
proc print data=myclass;
run;
1
PROC PRINTDATA=myclass;
2
RUN;
3 Code Block
PROC MEANS
Explanation : This PROC MEANS step calculates descriptive statistics (by default: N, mean, standard deviation, min, max) for the 'age' and 'heightcm' variables from the 'myclass' dataset. 'var' specifies the variables for which statistics should be calculated.
Copied!
proc means data=myclass;
var age heightcm;
run;
1
PROC MEANSDATA=myclass;
2
var age heightcm;
3
RUN;
4 Code Block
DATA STEP / PROC PRINT Data
Explanation : These two lines demonstrate that SAS is not sensitive to spacing. They create a 'myclass1' dataset identical to 'sashelp.class' and display it immediately. This is a condensed version of the previous blocks, illustrating syntax flexibility.
Copied!
data myclass1; set sashelp.class; run;
proc print data=myclass1; run;
1
2
DATA myclass1;
3
SET sashelp.class;
4
5
RUN;
6
PROC PRINT
7
DATA=myclass1;
8
9
RUN;
10
5 Code Block
DATA STEP Data
Explanation : This DATA STEP block creates an 'under13' dataset by selecting only observations from 'sashelp.class' where the 'AGE' variable is less than 13. The 'where' clause is used for filtering observations. Lines with asterisks are SAS comments.
Copied!
data under13;
set sashelp.class;
where AGE<13;
*comment with * should be end with semicolon;
*drop heIGht Weight;
run;
1
DATA under13;
2
SET sashelp.class;
3
where AGE<13;
4
*comment with * should be end with semicolon;
5
*drop heIGht Weight;
6
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.