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-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

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.

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