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;
Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!
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.