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: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 834 views
  • 2 likes
  • 4 in conversation