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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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