I created a code to read the datalines below,
data STD;
input Name : $5. Var1 Var2 Var3;
Mean = Mean(Var1, Var2, Var3);
STD1 = STD (Var1, Var2, Var3);
STD = round(STD1,0.01);
drop STD1;
datalines;
MATT 145 349 48
Susan 194 578 300
Tom 394 84 291
Jayce 394 58 279
;
run;
How can I create another data set that only contains one data step to show only observations that has STD less than or equal to 150?
None of the observations in the data you've posted appears to satisfy the condition - but here how you can write to two different tables in one go.
data STD std2;
input Name : $5. Var1 Var2 Var3;
Mean = Mean(Var1, Var2, Var3);
STD1 = STD (Var1, Var2, Var3);
STD = round(STD1,0.01);
drop STD1;
output std;
if std<=150 then output std2;
datalines;
MATT 145 349 48
Susan 194 578 300
Tom 394 84 291
Jayce 394 58 279
;
None of the observations in the data you've posted appears to satisfy the condition - but here how you can write to two different tables in one go.
data STD std2;
input Name : $5. Var1 Var2 Var3;
Mean = Mean(Var1, Var2, Var3);
STD1 = STD (Var1, Var2, Var3);
STD = round(STD1,0.01);
drop STD1;
output std;
if std<=150 then output std2;
datalines;
MATT 145 349 48
Susan 194 578 300
Tom 394 84 291
Jayce 394 58 279
;
Hi @skjhzzang
You can also write one statement to calculate the rounded standard deviation .
data want want2;
input Name : $5. Var1 Var2 Var3;
Mean=Mean(Var1, Var2, Var3);
STD=round(STD (Var1, Var2, Var3), 0.01);
if std <160 then output want2;
output want;
datalines;
MATT 145 349 48
Susan 194 578 300
Tom 394 84 291
Jayce 394 58 279
;
run;
proc print data=want;
run;
proc print data=want2;
run;
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.