Published on :
Statistical CREATION_INTERNE

Basic statistical analysis of internal data

This code is also available in: Deutsch Español Français
Awaiting validation
The first DATA STEP block, 'QUIZ3_1', reads ten numerical values (from 1 to 10) from a single line of data provided via the DATALINES statement. The use of 'input x @code_sas©_json/8_SAS©_Intro_ReadFile_MultiCol_@@.json;' creates a distinct observation for each numerical value read on the same line. Then, 'PROC MEANS' is used to calculate the number of observations ('num_observ') and the mean ('mean_val') of the variable 'x' from 'QUIZ3_1'. The NOPRINT option is specified to suppress the default display of the procedure results, and the OUTPUT statement is used to save the calculated statistics in a new temporary dataset. Finally, 'PROC PRINT' displays the content of this temporary dataset, specifically focusing on the 'num_observ' and 'mean_val' variables, which represent the count and mean of the processed data.
Data Analysis

Type : CREATION_INTERNE


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!
1DATA QUIZ3_1;
2 INPUT x @code_sas_json/8_SAS_Intro_ReadFile_MultiCol_@@.json;
3 DATALINES;
41 2 3 4 5 6 7 8 9 10
5;
6RUN;
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!
1 
2PROC MEANS noprint;
3OUTPUT n=num_observ mean=mean_val;
4RUN;
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!
1PROC PRINT;
2 var num_observ mean_val;
3RUN;
4QUIT;
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.