BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
sas_learnsups
Obsidian | Level 7

Hi all,

 

I have to check character values across 50 variables.I am using datastep where i am outp only those records who have the values. but getting error.

The program i am trying is somewht like this:

data test1;
set test;
do i=1 to 50 by 1;
if diagnosis_code&i like 'E10%' then output;
end;
run;

The dataset is huge like 19+ million records.(Can't think of transpose)

 

Thanks a lot in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star
I suspect you will have trouble with:

if codes[i] like 'E10%' then do;

If that's the case, switch to:

if codes[i] =: 'E10' then do;

Don't forget the colon after the equal sign. That's intentional and not a typo.

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

You want the observations having the diagnosis-code only once even if diagnosis_code1 and diagnosis_code4, for example, have "E10%"?

 

untested:

data want;
  set test;
  array codes[50] diagnosis_code1-diagnosis_code50;
  
  do i = 1 to dim(codes);
    if codes[i] like 'E10%' then do;
      output;
      leave;
    end;
  end;
run;
sas_learnsups
Obsidian | Level 7
Many thanks. Will check and let you know
Astounding
PROC Star
I suspect you will have trouble with:

if codes[i] like 'E10%' then do;

If that's the case, switch to:

if codes[i] =: 'E10' then do;

Don't forget the colon after the equal sign. That's intentional and not a typo.

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

How to connect to databases in SAS Viya

Need to connect to databases in SAS Viya? SAS’ David Ghan shows you two methods – via SAS/ACCESS LIBNAME and SAS Data Connector SASLIBS – in this video.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 4 replies
  • 921 views
  • 2 likes
  • 4 in conversation