The script begins by creating a temporary dataset named 'my_data' using a DATA STEP block with integrated data via DATALINES. This dataset contains a single numeric column, 'MyColumn'. Next, PROC SQL is used to calculate the mean of 'MyColumn' and rename the result column to 'Avg_MyColumn'. The script also uses PROC MEANS twice: first to generate a standard set of descriptive statistics for 'MyColumn', and a second time to specifically calculate and display only the mean of 'MyColumn'.
Data Analysis
Type : CREATION_INTERNE
The 'my_data' dataset is entirely created and populated within the SAS script itself, using the DATALINES statement. No external data sources or SASHELP libraries are used for this dataset.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block is responsible for creating the temporary SAS dataset named 'my_data'. It defines a single numeric variable, 'MyColumn', and inserts five observations (1, 2, 3, 4, 5) directly from the DATALINES section. The 'RUN;' statement marks the end of the DATA step and the execution of the dataset creation.
Explanation : This PROC SQL calculates the mean of the 'MyColumn' column from the 'my_data' dataset. The mean result is renamed 'Avg_MyColumn' for better readability in the output. The 'QUIT;' statement ends the execution of the PROC SQL step.
Copied!
PROC SQL;
select avg(MyColumn) as Avg_MyColumn
from my_data;
QUIT;
1
PROC SQL;
2
select avg(MyColumn) as Avg_MyColumn
3
from my_data;
4
QUIT;
3 Code Block
PROC MEANS
Explanation : This PROC MEANS is used to generate basic descriptive statistics for the 'MyColumn' variable from the 'my_data' dataset. By default, PROC MEANS will display N (number of observations), mean, standard deviation, minimum, and maximum values. The 'RUN;' statement executes the procedure.
Copied!
PROC MEANS DATA=my_data;
var Mycolumn;
RUN;
1
PROC MEANSDATA=my_data;
2
var Mycolumn;
3
RUN;
4 Code Block
PROC MEANS
Explanation : This second PROC MEANS is similar to the previous one but uses the 'mean' option to specifically request and display only the mean of the 'MyColumn' variable from the 'my_data' dataset. This allows for a more targeted output of the desired statistics. The 'RUN;' statement executes the procedure.
Copied!
PROC MEANS DATA=my_data mean;
var Mycolumn;
RUN;
1
2
PROC MEANS
3
DATA=my_data mean;
4
var Mycolumn;
5
RUN;
6
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.