Here's a good primer on Macros. It's short read that should help clear things up.
http://www.ats.ucla.edu/stat/sas/seminars/sas_macros_introduction/
Also, review step one and step 4 in my instructions and compare it to your code, you made some mistakes but are close.
I am puzzled with step 4 and do not know how to modify my code. Would you please let me know my mistakes?
Thanks.
%let sum=child adult senior over100;
%macro sum;
proc sort data=bp2∑
by patientid;
run;
PROC means data=bp2∑
var wvr_:;
run;
%mend;
%let data = %sum;
@Bal23 Do you know how to run a macro? I don't understand the insistence of macro code - to me it sounds like homework then.
I know the theory a little bit, but I do not know how to write
i usually modify very simple ones but get lost when there are new problems, that need me to be creative
would you please give advice
I'm going back to my first point.
I highly recommend this method because you get less errors and it's easier to implement for beginners. Learn the basics first.
In this structure you'll be able to easily compare freqs using a table statement. Let's assume that the variable that identifies your data set is called DATASET_NAME, then you can write your proc freq as follows. The variable values will be listed on the left and the data source across the top. I don't think your comparison can get any easier :).
Good Luck...I think I've chimed in enough on this thread.
proc freq data=combined;
table my_var*dataset_name;
run;
Thanks. I have devloped code previously, without macro; but I am interested in sas macro.
Thus I wrote my macro code, it works.
I am not very satified with the current code and think it can be improved. I hope to get advice from you how to make it more concise and be more efficient.
Then, go back to your post. I just do not know how to use INDSNAME option.
My problem is, I want to have sas code to compare the frequency of those variables "wvr_" and list it in that order by frequency.
Would you please give me better advice.
%let ageg= child;
%macro doit;
proc sort data=bp2&ageg;
by patientid;
run;
Title1 "2. body system, &ageg";
PROC means DATA=bp2&ageg;
var wvr_:;
run;
%mend doit;
%let ageg= adult;
%doit
%let ageg= senior ;
%doit
%let ageg= over100;
%doit
run;
Change your macro to take a parameter.
*this was step 4 in the instructions;
%macro doit(ageg);
***Rest of code***;
%mend;
%doit(child);
%doit(adult);
..
%doit(..);
Did you run the sample code I provided for INDSNAME? What doesn't make sense?
INDSNAME is short for INput DataSet NAME
That's what it does, identify what dataset the data came from.
Thank you. I read your posts several times. I have to piece your two posts together. To a certain degree, I am confused.
My sas got busy when I put those four datasets together. That slows down the process. Would you please put your two posts together so that I can see how it is?
Thanks.
INDSNAME is not related to the macro. You can do this two ways.
Pick one and go with it.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: