Good Night:
I'm trying to create data based in PROC MEANS, i need to use the information that PROC MEANS offers.
Thank you very much
Thank you Reeza for your help:
Now, it worked out, and new doubt born again (LOL).
I've got 2 PROC MEANS procedures like this:
PROC MEANS DATA= data1 MEAN;
OUTPUT OUT=mean1;
RUN;
PROC MEANS DATA= data2 MEAN;
OUTPUT OUT=mean2;
RUN;
My question is: HOW TO CREATE A NEW DATASET USING THE DIFERENCE BETWEEN DATA ONE AND TWO (mean1 - mean2)
Thank you very much
You'll need to combine the data sets.
Data want;
set data1 data2 (in=in2);
/* at this point I don't have any hard code to provide as you don't have any variables provided but for each variable*/
DifVariablename = Dif (Variablename);
If in2;
run;
The DIF function gives the subtraction across rows. You could use Variablename=Dif(variablename); if you don't care that your value is now actually the difference of means instead of an actual mean.
You need to merge the data sets. I would also add names to each of the variables to help clarify the results.
proc means data=data1 noprint;
var var_interest;
output out=mean1 mean(var_interest)=mean_var_interest1;
run;
proc means data=data2 noprint;
var var_interest;
output out=mean2 mean(var_interest)=mean_var_interest2;
run;
data diff;
merge mean1 mean2;
diff = mean_var_interest1- mean_var_interest2;
run;
I would just use an OUTPUT statement with an OUT= option.
PROC MEANS DATA=SASHELP.CLASS
MEAN MIN MAX SKEW N;
OUTPUT OUT=WORK.NEWDATA;
RUN;
PROC PRINT DATA=WORK.NEWDATA;
RUN;
In the PROC MEANS statement just assign whatever options you'd like to display (if you don't want the default) and use the OUT= option to name the output data set.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.