BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
jonatan_velarde
Lapis Lazuli | Level 10

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

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
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

6 REPLIES 6
Reeza
Super User
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...
jonatan_velarde
Lapis Lazuli | Level 10

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

ballardw
Super User

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.

 

Reeza
Super User

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;
jonatan_velarde
Lapis Lazuli | Level 10
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
KyleM_Corrie
Fluorite | Level 6

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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 6 replies
  • 1175 views
  • 0 likes
  • 4 in conversation