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

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?

 

1 ACCEPTED SOLUTION

Accepted Solutions
Patrick
Opal | Level 21

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
;

View solution in original post

3 REPLIES 3
Patrick
Opal | Level 21

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
;
ed_sas_member
Meteorite | Level 14

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;

 

SAS Innovate 2025: Call for Content

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!

Submit your idea!

How to Concatenate Values

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.

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
  • 453 views
  • 1 like
  • 4 in conversation