Hi. I need to look for the given diagnostic codes which might have multiple categories within it in my cohor. I want to assign a macro variable with all the codes so I can write :
Data want ;
Set have ;
Where code index or substr ¯o. ;
Run ;
Where ¯o. Is the macro variable containing the codeslist.
Codelist . These are ICD9 codes and can have subcategories like 001 – 001.1, 001.2 etc.
I want to use index or substring function
001 |
002 |
003 |
004 |
005 |
006 |
007 |
008 |
009 |
010 |
011 |
012 |
013 |
014 |
015 |
016 |
017 |
018 |
020 |
021 |
022 |
023 |
024 |
025 |
026 |
027 |
030 |
031 |
032 |
033 |
034 |
035 |
036 |
037 |
038 |
039 |
040 |
041 |
042 |
045 |
046 |
047 |
048 |
049 |
050 |
051 |
052 |
053 |
054 |
055 |
056 |
057 |
060 |
061 |
062 |
063 |
064 |
065 |
066 |
070 |
071 |
072 |
073 |
074 |
075 |
076 |
077 |
078 |
079 |
080 |
081 |
082 |
083 |
084 |
085 |
086 |
087 |
088 |
090 |
091 |
092 |
093 |
094 |
095 |
096 |
097 |
098 |
099 |
100 |
101 |
102 |
103 |
104 |
I need to look for the given diagnostic codes which might have multiple categories within it in my cohor. I want to assign a macro variable with all the codes so I can write :
Data want ;
Set have ;
Where code index or substr ¯o. ;
Run ;
Where ¯o. Is the macro variable containing the codeslist.
Codelist . These are ICD9 codes and can have subcategories like 001 – 001.1, 001.2 etc.
I want to use index or substring function
This is really unclear to me, in particular, I don't really understand the part in red. You need to provide a lot more detail about what you are trying to do and what you want as the result.
Quite simply don't. You will come across a whole realm of problems, extra coding, code falling over etc if you do. Put data in datasets - this is what they are for. Then you can query them etc.:
Assumes I have:
001 |
002 |
003 |
In a dataset called list:
proc sql; create table want as select * from have where code in (select code from list); quit;
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.