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
PROC Star

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
PROC Star

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

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