BookmarkSubscribeRSS Feed
sneha_dodle
Fluorite | Level 6
I have a dataset with variables site,subjid,race,ethinicity,sex. How do i get them all in one column using proc report. My output should contain site\subjid\race\ethnicity\sex in one column
5 REPLIES 5
andreas_lds
Jade | Level 19

Maybe using compute statement, but it is easier to  create one variable using a data step:

 

Untested code:

data work.combined;
  set have;
  
  length combined $ 100; /* add the length of the variables to avoid data-loss */
  
  combined = catx('\', site, subjid, race, ethnicity, sex);
run;
sneha_dodle
Fluorite | Level 6
How do i apply formats those variables listed in the catx function?
andreas_lds
Jade | Level 19

If the variables are already formatted, use vvalue(variable) in catx. If not, use put-function, to apply formats while combining.

RW9
Diamond | Level 26 RW9
Diamond | Level 26

If you want the data concatenated for a report, then it is a good idea to do this in a dataset before the proc report step.  Have a variable specifically for the concatenated data say:

data want;
  set have;
  length demo $200;
  demo=catx("\",site,subjid,race,ethnicity,sex);
run;

Then proc report that.  Whilst proc report can do computed, you will want to have that information in the dataset you store for double programming/QC.  

ballardw
Super User

Example data.

 

Example of desired output.

 

Otherwise we are likely to get many "that doesn't work" from you because we have to make a lot of assumptions about values involved.

 

In general, proc report is going to want a single "column" to be of the same type with a single format for each cell of the format with exceptions for computed summaries.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 5 replies
  • 1572 views
  • 2 likes
  • 4 in conversation