The data is directly integrated into the SAS script as datalines, allowing immediate reading and processing without dependence on external files.
1 Code Block
DATA STEP Data
Explanation : This DATA STEP block initializes and populates the 'QUIZ3_1' dataset. The 'input x @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;' statement is crucial here: it reads each number from the 'DATALINES' row into the 'x' variable and creates a new observation for each number, while maintaining the read pointer on the same logical line until all values are read. This allows transforming a single physical line of data into multiple observations in the 'QUIZ3_1' dataset.
Copied!
DATA QUIZ3_1;
input x @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
datalines;
1 2 3 4 5 6 7 8 9 10
;
RUN;
1
DATA QUIZ3_1;
2
INPUT x @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
3
DATALINES;
4
12345678910
5
;
6
RUN;
2 Code Block
PROC MEANS
Explanation : This procedure calculates descriptive statistics for the previously created dataset. The 'NOPRINT' option prevents the procedure's standard output from appearing in the log or results. The 'OUTPUT' statement is used to create a new (temporary, by default) dataset containing the number of observations (N) under the 'num_observ' variable and the mean (MEAN) of the 'x' variable under the 'mean_val' variable.
Copied!
PROC MEANS noprint;
output n=num_observ mean=mean_val;
RUN;
1
2
PROC MEANS noprint;
3
OUTPUT n=num_observ mean=mean_val;
4
RUN;
5
3 Code Block
PROC PRINT
Explanation : This procedure displays the content of the dataset generated by PROC MEANS. The 'VAR num_observ mean_val;' statement specifies that only these two variables should be included in the printed output, thus concisely presenting the calculated summary statistics.
Copied!
PROC PRINT;
var num_observ mean_val;
RUN;
QUIT;
1
PROC PRINT;
2
var num_observ mean_val;
3
RUN;
4
QUIT;
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.