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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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