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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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