May 27, 2021 SAS
Standard deviation (SD) is a measure of how the data in the data set changes. M athematically, it measures the distance or proximity of each value to the average of the dataset. A standard deviation value close to 0 indicates that the data point tends to be very close to the average of the dataset, and a high standard deviation indicates that the data point expands over a wider range of values.
In SAS, SD values are measured using PROC MEAN and PROC SURVEYMEANS.
To measure the SD using proc, we select the STD option in the PROC step. I t outputs SD values for each numeric variable that exists in the data set.
The basic syntax for calculating standard deviations in SAS is:
PROC means DATA = dataset STD;
Here is a description of the parameters used:
In the following example, we create a dataset, CARS1, from the CARS dataset in theASHELP library. W e select the STD option with proC mean step.
PROC SQL; create table CARS1 as SELECT make,type,invoice,horsepower,length,weight FROM SASHELP.CARS WHERE make in ('Audi','BMW') ; RUN; proc means data=CARS1 STD; run;
When we execute the code above it provides the following output:
The program is also used to measure SD and some advanced features, such as measuring the SD of a classification variable and providing an estimate of variance.
The syntax for USPROC SURVEYMEANS is:
PROC SURVEYMEANS options statistic-keywords ; BY variables ; CLASS variables ; VAR variables ;
The following is a description of the parameters used:
The following example describes using the class option to create statistics for each value in a class variable.
proc surveymeans data=CARS1 STD; class type; var type horsepower; ods output statistics=rectangle; run; proc print data=rectangle; run;
When we execute the code above it provides the following output:
The following code gives an example of the BY option. I n it, the results are grouped by each value of the BY option.
proc surveymeans data=CARS1 STD; var horsepower; BY make; ods output statistics=rectangle; run; proc print data=rectangle; run;
When we execute the code above it provides the following output: