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;
If the variables are already formatted, use vvalue(variable) in catx. If not, use put-function, to apply formats while combining.
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.
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.
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.
Ready to level-up your skills? Choose your own adventure.