BookmarkSubscribeRSS Feed
3 REPLIES 3
jimbarbour
Meteorite | Level 14

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

ChrisNZ
Tourmaline | Level 20

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

Kurt_Bremser
Super User

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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 926 views
  • 0 likes
  • 4 in conversation