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 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 6623 views
  • 4 likes
  • 3 in conversation