SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
x3d1m4
Fluorite | Level 6

Its is possible extract "means "and "std" from another data step and make it a solid value than I can paste in PROC STANDARD? Here is my unfinished example

 

data what_i_have;
input x1 x2 x3;
cards;
1 2 3
4 5 6
7 8 9
;
run;
proc means data=what_i_have mean std;
output out=mean_x1 mean= std= /autoname;
run;

proc standard data=what_i_have out=what_i_want  mean = "here i want paste my mean from choosen variable" std= "here i want paste my std ";
var x1 */ I want here iterate through every variable */;
run;

 

The best 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

This is possible to do the way you describe. However, I wonder if there is a better way. Is your goal to standardize data, i.e. subtract the mean of a variable and divide by the variable's standard deviation? If so, there are better ways.

 

For example, see the article 4 ways to standardize data in SAS by @Rick_SAS .

Reeza
Super User

Here's one way.

https://github.com/statgeek/SAS-Tutorials/blob/master/add_average_value_to_dataset.sas

 

PROC STDIZE will also standardize variables and calculate the mean/standard deviation as needed.

 


@x3d1m4 wrote:

Its is possible extract "means "and "std" from another data step and make it a solid value than I can paste in PROC STANDARD? Here is my unfinished example

 

data what_i_have;
input x1 x2 x3;
cards;
1 2 3
4 5 6
7 8 9
;
run;
proc means data=what_i_have mean std;
output out=mean_x1 mean= std= /autoname;
run;

proc standard data=what_i_have out=what_i_want  mean = "here i want paste my mean from choosen variable" std= "here i want paste my std ";
var x1 */ I want here iterate through every variable */;
run;

 

The best 


 

PaigeMiller
Diamond | Level 26

@x3d1m4 wrote:

Its is possible extract "means "and "std" from another data step and make it a solid value than I can paste in PROC STANDARD? Here is my unfinished example

 

data what_i_have;
input x1 x2 x3;
cards;
1 2 3
4 5 6
7 8 9
;
run;
proc means data=what_i_have mean std;
output out=mean_x1 mean= std= /autoname;
run;

proc standard data=what_i_have out=what_i_want  mean = "here i want paste my mean from choosen variable" std= "here i want paste my std ";
var x1 */ I want here iterate through every variable */;
run;

PROC STDIZE will do this for you without the PROC MEANS step and without you having to paste anything, and it will do it for every variable with one call to the PROC.

 

proc stdize data=what_i_have method=std out=what_i_want;
    var x1 x2 x3;
run;
--
Paige Miller
SurajSaini
Obsidian | Level 7
Use Proc sql to extract mean and std here is an exaple:

proc sql;
SELECT AVG(Variable)
INTO: M
FROM Dataset_Name;
SELECT STD(Variable)
INTO: S
FROM Dataset_Name;
QUIT;
RUN;
----------------------------------------- CREATE NEW VARIABLES-----------------------------
DATA what_i_have;
SET what_i_have;
M=&M;
S=&S;
RUN;
------------------------------------PUT INTO PROC STANDARD----------------------------------
proc standard data=what_i_have out=what_i_want mean = M std= S;
var x1 */ I want here iterate through every variable */;
run;

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

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
  • 4 replies
  • 1798 views
  • 4 likes
  • 5 in conversation