DATA Step, Macro, Functions and more

Macro for Frequency Table output with Variable Label & Value Format

Reply
N/A
Posts: 0

Macro for Frequency Table output with Variable Label & Value Format

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.
N/A
Posts: 0

Re: Macro for Frequency Table output with Variable Label & Value Format

Posted in reply to deleted_user
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.
Ask a Question
Discussion stats
  • 1 reply
  • 436 views
  • 0 likes
  • 1 in conversation