Were I to try something like this, I would switch from Proc Print to Proc Report. Proc Report has COMPUTE blocks that could allow you to blank out certain variables.
Jim
To have such a customised output, I would print directly from the data step.
Two solutions:
- The easy and less flexible one, using ODS Output in the Data Step.
- The more complex and more flexible one, using the ODS Data Step Object
First, transpose into a long dataset, and then use SQL to extract all combinations of your wanted values. To achieve the final display, you will have to use a DATA step again (see the log for a possible example output):
data have;
infile datalines dlm=',' dsd truncover;
input ID Hlth_1 Hlth_2 Hlth_3 imun_1 imun_2;
datalines;
1,999,444,666,999,198
2,777,666,666,222
3,999,777,999
4,333,222,222,222
5,555,222
6,888,999,,111,999
7,444,333,,444
;
proc transpose data=have out=long;
by id;
var hlth: imun:;
run;
proc sql;
create table want as
select
h.id,
h._name_ as n_hlth,
h.col1 as hlth,
i._name_ as n_imun,
i.col1 as imun
from long h, long i
where
h.id = i.id and
upcase(h._name_) like 'HLTH%' and
h.col1 = 999 and
upcase(i._name_) like 'IMUN%' and
i.col1 = 999
;
quit;
data _null_;
set want;
put @1 id @10 n_hlth @20 n_imun;
put @10 hlth @20 imun;
run;
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.