BookmarkSubscribeRSS Feed
SM1
Obsidian | Level 7 SM1
Obsidian | Level 7

They are an exact match.

 

The records being affected are only those records that don't include any of the 4 ICD 10 codes - they include other ICD 10 codes, just not those 4 specific codes.

 

Even though they don't contain those codes, I need to keep the records.

 

I was going to set the new variable CMDX = 0 at the start of the syntax where it's length and format are defined, but if I do that, it would compromise the statement "if missing (CMDX) then CMDX = dx(i);"

Reeza
Super User

@SM1 wrote:

The records being affected are only those records that don't include any of the 4 ICD 10 codes - they include other ICD 10 codes, just not those 4 specific codes.

 

Even though they don't contain those codes, I need to keep the records.

 

All the observations should have the CMDX variable populated with onle of the four DX's  because all observations contain at least one of these diagnoses.

 

I don't think there's anything in the code I provided that deletes records. It would be missing, or you can set it to any other variable you want, including the text 'Missing'.  Also, this doesn't match what you stated earlier. 

 

I added in some comments, hopefully it helps you to understand the code better.

 

data palms.FM01_DX;
set palms.fm01_ela;

*Initialize CMDX variable type and value;
length CMDX $8.;
format CMDX $8.;
CMDX='MISSING';

*Set array that holds codes you're looking for;
array find_dx(4) $ _temporary_ ('DOD0301', 'DOD0302', 'DOD0303',
'Z0289');
*Create array that is for diagnosis codes fields;
array dx(10)$ dx1-dx10;

*Loop over values you're searching for;
do i=1 to 4;
*If a diagnosis that matches a value of interest then assign it to the CMDX;
if whichc (find_dx(i), of dx(*))>0 then do;
if CMDX='MiSSING' then CMDX = dx(i);
end;

end;

run;

 

 

 

Reeza
Super User
Set it to anything else then and check for that value as long as it doesn't conflict with dx codes. But its a character not numeric so 0 isn't valid, but you can use CMDX=0;

Then use
If cmdx=0 then ...
SM1
Obsidian | Level 7 SM1
Obsidian | Level 7

Thank you for all the suggestions.

 

I don't lose the observations so long as I remove the statement "output;"

 

Thanks again for your help!

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 18 replies
  • 3221 views
  • 0 likes
  • 3 in conversation