BookmarkSubscribeRSS Feed
deleted_user
Not applicable
Can anybody be kind of help solving the problem in my Macro?

The data is from a large scale survey. The purpose of this macro is to generate and output a distribution.frequency results of a specified variable as a file, within the file the variable lable is used instead of variable, and the recoded value of the variable is used ithrough Variable format instead of the original variable value. Variable has already been formated/recoded.

Since the variable label is too long, so I want to assign a macro variable to it first.

The SAS codes are as the following:

%let Q1_label='abcdefgh';

%macro f_freq(var, var_w, var_label);
proc freq data= clean_data order=freq;
table &var /out=freqout.freq_&var;
format &var &var_w;
label &var=&var_label;
run;
%mend;

%f_freq(Q1,Q1_w., Q1_label);


Great thanks in advance.
1 REPLY 1
deleted_user
Not applicable
Perhaps
%f_freq(Q1,Q1_w., Q1_label);

should be
%f_freq(Q1,Q1_w., &Q1_label);

Also, check your quoting. Use some %put statements to help you see what the macro variables really contain.

Next.
I believe the format and the label are used for reporting/printing/display purposes.
I don't think they will affect the aggregation.
Am I mis-interpreting your intent?
Since I haven't used proc freq in ages, I may be wrong in my interpretation of what it will do.

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 1710 views
  • 0 likes
  • 1 in conversation