Creating data from PROC MEANS

Accepted Solution Solved
Reply
Frequent Contributor
Posts: 103
Accepted Solution

Creating data from PROC MEANS

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


Accepted Solutions
Solution
‎12-04-2015 05:27 AM
Grand Advisor
Posts: 17,313

Re: Creating data from PROC MEANS

You have two options, in addition to other procs.
One is the OUTPUT OUT= syntax and the other is the ODS Tables. This example demonstrates both, as well as the STACKODS option that formats the tables.

https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p17h6q7ygvkl1sn13qzf...

View solution in original post


All Replies
Solution
‎12-04-2015 05:27 AM
Grand Advisor
Posts: 17,313

Re: Creating data from PROC MEANS

You have two options, in addition to other procs.
One is the OUTPUT OUT= syntax and the other is the ODS Tables. This example demonstrates both, as well as the STACKODS option that formats the tables.

https://support.sas.com/documentation/cdl/en/proc/65145/HTML/default/viewer.htm#p17h6q7ygvkl1sn13qzf...
Frequent Contributor
Posts: 103

Re: Creating data from PROC MEANS

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

Grand Advisor
Posts: 10,196

Re: Creating data from PROC MEANS

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.

 

Grand Advisor
Posts: 17,313

Re: Creating data from PROC MEANS

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;
Frequent Contributor
Posts: 103

Re: Creating data from PROC MEANS

Very nice Answer my friend:

Well, continuing this programation:

Following your guides i made this data:

data dif_want;
merge mean1 mean2;
diff = mean_var_interest1 - mean_var_interest2;
a0 = (mean_var_interest1- mean_var_interest2)/30;
b0 = log(a0/mean_var_interest2);
b1 = b0/10;
run;

I need to use a0 b0 and b1 in here:

proc nlin data=any_other_dataset plots=all method=marquardt;
parms a0 = a0 b0 = b0 b1 = b1;
model response=a0*exp(exp(b0)*(exp(b1*observation)-1)/b1);
id Sample;
output out=est_ind1 p=pred r=resid parms=a0 b0 b1;
run;

/thanks
Occasional Contributor
Posts: 12

Re: Creating data from PROC MEANS

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.

☑ This topic is SOLVED.

Need further help from the community? Please ask a new question.

Discussion stats
  • 6 replies
  • 404 views
  • 0 likes
  • 4 in conversation