Hello!
Suppose I have a column called 'Diff' in a dataset:
Diff
23.56
45.77
23.67
67.86
24.97
86.45
I want to calculate the standard deviation (a single value= 26.66928) of Diff (it's not a rolling standard deviation).
My variable for standard deviation is SD_A. What should be the code to get a single value of SD_A which I will need for further calculation?
Much thanks.
Then you could start with:
proc sql;
create table want as
select *, std(diff) as sd_a
from have;
quit;
And you could use the same step to do some more calculations with diff and sd_a.
There are countless ways. Here is one, assuming Diff is a variable in dataset have:
proc summary data=have;
output out=want std(diff)=sd_a;
run;
The std will be in dataset want.
@PGStats, Thank you so much. However, I need to work with 'Have' dataset, and use SD_A. If the SD_A in a different dataset, how can I make use of it in 'Have'?
I appreciate your time. Much thanks.
Then you could start with:
proc sql;
create table want as
select *, std(diff) as sd_a
from have;
quit;
And you could use the same step to do some more calculations with diff and sd_a.
Nearly 200 sessions are now available on demand with the SAS Innovate Digital Pass.
Explore Now →SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.