BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
d6k5d3
Pyrite | Level 9

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. 

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

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.

 

PG

View solution in original post

3 REPLIES 3
PGStats
Opal | Level 21

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.

PG
d6k5d3
Pyrite | Level 9

@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.

PGStats
Opal | Level 21

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.

 

PG

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 3 replies
  • 7766 views
  • 1 like
  • 2 in conversation