BookmarkSubscribeRSS Feed
Cruise
Ammonite | Level 13

I'd like to eliminate patients with certain diseases from data "have" to a "want" using Prxmatch function. The list of ineligible diagnosis can be very long so reading the list in csv file was the option to go for me. I know for sure that HAVE data is supposed to keep almost all patients into WANT data according to my manual check. However, i keep getting LOG below saying no observations output into WANT. Btw, attached is the sample data. SAS data was not allowed so is exported to csv file to attach to this post. 

 

Log:

NOTE: There were 6477 observations read from the data set HAVE
NOTE: The data set WANT has 0 observations and 30 variables.

 

Code:

 

data icda(rename=(x=preterm_icd y=types_icd)); set icd;
 format y $10.;
  defect_original=types_icd;
 if types_icd ne " " then y="[*]"||types_icd;
 format x $10.;
  /*icd_new=compress(other_icd,'.');
  icd_original=other_icd;
  x="[*]"||icd_new;
 drop other_icd types_icd defect_original icd:;*/
 run;

/*please ignore part commented out above. i left it just to show that there
was a step preceded to subset data using Prxmatch as well. Step 1 worked fine, no prob*/ proc sql noprint; select types_icd into :types separated by '|' from icda; quit; %put &types; %let x=:Other_Diagnosis_Code_1 - :Other_Diagnosis_Code_10; %macro loop(case); %global case1; %let case1=&case; %if &case=all_types %then %let condition1 = &types; data want; set have; icd_code = catx('*','*',Principal_Diagnosis_Code, of Other_Diagnosis_Code:); if prxmatch("m/&condition1/oi",icd_code) = 0; source="Internal"; run; %mend loop; %loop(all_types);

 

Any suggestions for a trouble shooting?

Thanks.

5 REPLIES 5
ballardw
Super User

There is a macro available to create data step code that you can paste here for example data. Unfortunately a simple CSV file does not necessarily tell us what varaible type you have assigned to specific variables plus we have to write code to read said data and may not have the time as volunteers.

 

Instructions here: https://communities.sas.com/t5/SAS-Communities-Library/How-to-create-a-data-step-version-of-your-dat... will show how to turn an existing SAS data set into data step code that can be pasted into a forum code box using the {i} icon or attached as text to show exactly what you have and that we can test code against.

Cruise
Ammonite | Level 13
Thanks, I will teach myself the content in the link. Will take me few hours. Thanks for response anyway.
Cruise
Ammonite | Level 13
Hi Ballardw, is there SAS version of creating sample data? I don't have a SAS studio.
Cruise
Ammonite | Level 13

Just trouble shooted this problem. I will update the post with a solution when I get a chance. 

Cruise
Ammonite | Level 13

Solution out of macro. It helped only when list of condition to look up was short enough just to list in the code itself. 

 

data want; set have
array x Main_Diagnosis Other_Diagnosis_1-Other_Diagnosis_24; 
do over list;
if x=list in :("P","C", "H"......) 
then a=1;
end;
if a=1 then output;
run;

 

With macro and loop solution because I had looong list of diseases to eliminate from the dataset that would be too tedious ...

proc import
 datafile="…\icd.csv" out=icd
 dbms=csv replace;
 getnames=yes;
run;

data icda(rename=(x=types_icd y=diseases_icd)); set icd;
 format y $10.;
  defect_original=diseases_icd;
 if diseases_icd ne " " then y="[*]"||diseases_icd;
 format x $10.;
  icd_new=compress(types_icd,'.');
  icd_original=types_icd;
  x="[*]"||icd_new;
 drop types_icd diseases_icd defect_original icd:;
 run;

proc sql noprint;
     select  diseases_icd
     into :diseases separated by '|'
     from  icda(where=(diseases_icd ne " "));
quit;

proc sql noprint;
   select  types_icd
     into :types separated by '|'
     from  icda;
quit;

%let x=:Other_Diagnosis_1 - :Other_Diagnosis_10;

data want; set have;       
icd_code = catx('*','*',Main_diagnosis, of Other_Diagnosis_Code:); 

if prxmatch("m/&types/oi",icd_code) > 0 and prxmatch("m/&diseases/oi",icd_code) = 0; /* types with no diseases */

run;

 

 

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 5 replies
  • 826 views
  • 1 like
  • 2 in conversation