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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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.

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