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

Basically, to use Standard deviation function (STD), I know that I can use it as STD = STD(Var1, Var2, Var3);

but how about if I have 100 numerical variables?

In input statement, I know that it is possible to use like this, input Var1 - Var100;

Then, for STD function, do I have to write all 100 variables into parenthesis?

 

1 ACCEPTED SOLUTION

Accepted Solutions
ed_sas_member
Meteorite | Level 14

Hi @skjhzzang 

 

You can use an array to do that. You can then refer to the array name e.g. myarray(*) in a function like below:

 

data STD std2;
	input Name : $5. Var1 Var2 Var3;
	array myarray (*) Var1 - Var3; /* Reference you variables once */

	do i=1 to dim(myarray);
		Mean=Mean(of myarray(*));
		std=round(std(of myarray(*)), 0.01);
	end;
	drop i;
	
	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
;
run; 

 

View solution in original post

3 REPLIES 3
ed_sas_member
Meteorite | Level 14

Hi @skjhzzang 

 

You can use an array to do that. You can then refer to the array name e.g. myarray(*) in a function like below:

 

data STD std2;
	input Name : $5. Var1 Var2 Var3;
	array myarray (*) Var1 - Var3; /* Reference you variables once */

	do i=1 to dim(myarray);
		Mean=Mean(of myarray(*));
		std=round(std(of myarray(*)), 0.01);
	end;
	drop i;
	
	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
;
run; 

 

PaigeMiller
Diamond | Level 26
stdev=std(of var1-var100);
--
Paige Miller

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 25. 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
  • 619 views
  • 0 likes
  • 4 in conversation