SAS Procedures

Help using Base SAS procedures
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bronco
Calcite | Level 5

Please help. I'm trying to calculate the std deviation of a variable and output as a new variable.

used: sales_dev = std(sales);

got this error message;

 

ERROR 71-185: The STD function call does not have enough arguments.

 

Thanks

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
Since SAS processes data row by row, thats not quite how it works. The STD() function in a data step is intended to compute the STD of a set of values in the same row.

Proc means is the way to calculate it for a column.

Proc means data=sashelp.class;
Var weight;
Output out=want;
Run;

To get it merged back into the data step merge it back in.

You can also use SQL where the function behaves as expected but SQL does not and will merge it in directly 😀 You do get a note in the log which many places frown upon.

Proc sql;
Create table want2 as
Select *, std(weight) as std_var
From sashelp.class;
Quit;

View solution in original post

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16
std function requires atleast two variables, since you mentioned only one it is giving this error. Also i believe you are using this std in data step, if you have only one variable then please use group by statement
Thanks,
Jag
Reeza
Super User
Since SAS processes data row by row, thats not quite how it works. The STD() function in a data step is intended to compute the STD of a set of values in the same row.

Proc means is the way to calculate it for a column.

Proc means data=sashelp.class;
Var weight;
Output out=want;
Run;

To get it merged back into the data step merge it back in.

You can also use SQL where the function behaves as expected but SQL does not and will merge it in directly 😀 You do get a note in the log which many places frown upon.

Proc sql;
Create table want2 as
Select *, std(weight) as std_var
From sashelp.class;
Quit;
Reeza
Super User
If you want to calculate the std for specific groups, add them into a GROUP BY clause.

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 6929 views
  • 4 likes
  • 3 in conversation