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

SAS INNOVATE 2024

Innovate_SAS_Blue.png

Registration is open! SAS is returning to Vegas for an AI and analytics experience like no other! Whether you're an executive, manager, end user or SAS partner, SAS Innovate is designed for everyone on your team. Register for just $495 by 12/31/2023.

If you are interested in speaking, there is still time to submit a session idea. More details are posted on the website. 

Register now!

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.

Get the $99 certification deal.jpg

 

 

Back in the Classroom!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 1143 views
  • 2 likes
  • 2 in conversation