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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 886 views
  • 0 likes
  • 4 in conversation