BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
lizzy28
Quartz | Level 8

Hi everyone,

 

I'd like to ask if there is an easy to way to do crosstab of many variables with the same prefix.

 

For my data, there are 45 fields, Q1-Q45, and 45 corresponding recoded variables based on Q1-Q45, rQ1-rQ45. I want to make sure that the recoding is done right by checking crosstab like

proc freq data=mydata;

  table Q1*rQ1 Q2*rQ2 Q3*rQ3 …  Q45*rQ45;

run;

 

I want to have something quick rather than typing each set from Q1 to Q45. Any thoughts?

 

Thank you!

Lizi

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

A simple macro would work

 

%macro dothis;
proc freq data=mydata;
  table %do i=1 %to 45; Q&i*rQ&i %end; ;
run;
%mend;
%dothis

 

--
Paige Miller

View solution in original post

1 REPLY 1
PaigeMiller
Diamond | Level 26

A simple macro would work

 

%macro dothis;
proc freq data=mydata;
  table %do i=1 %to 45; Q&i*rQ&i %end; ;
run;
%mend;
%dothis

 

--
Paige Miller
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2129 views
  • 2 likes
  • 2 in conversation