🔒 This topic is solved and locked.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 01-19-2016 05:32 PM
(6891 views)
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
3 REPLIES 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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
Jag
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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;
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;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
If you want to calculate the std for specific groups, add them into a GROUP BY clause.