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

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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.

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