I am stuck trying to read a macro variable containing a list of values by using the %scan function to find which list is going to be scanned for a value. Here is an example:
1. I have the following list;
%let list_cci=MI CHF CVD PVD DEM CPD CTDRD PUD MLD diab_wc diab_c P_H RD CAN MSLD MC HIV;
2. Each value of this list is another list, as following:
%let MI=410 412;
%let CHF=39891 40201 40211 4291 40401 40403 40411 40413 40491 40493 4254 4255 4257 4258 4259 428;
...
3. The idea is that I want to scan the list, assign a value to a macro variable, and then use that macro variable to tell sas which list to scan for another value. I need to do this in 2 steps because the variable name (MI, CHF, CVD, etc.) is important. However, when
4. Here is what I have done so far, within 2 %do loops that run from 1 to &i and &j:
%let diagname = &%scan(&list_cci.,&i.);
%put &diagname; /*gives me e.g. &MI */
%let var=%scan(&diagname,&j.); /*--->here I expect it would scan the MI list, because &MI is put in the %scan function*/
%put &var; /* but all I get is the jth value from the &list_cci list... even though %put &diagname; gives me &MI!*/
Any ideas why it would scan the first list when I ask to basically %scan(&MI,&j.)? Any other idea how I could solve this?
1. I have the following list;
%let list_cci=MI CHF CVD PVD DEM CPD CTDRD PUD MLD diab_wc diab_c P_H RD CAN MSLD MC HIV;
2. Each value of this list is another list, as following:
%let MI=410 412;
%let CHF=39891 40201 40211 4291 40401 40403 40411 40413 40491 40493 4254 4255 4257 4258 4259 428;
...
3. The idea is that I want to scan the list, assign a value to a macro variable, and then use that macro variable to tell sas which list to scan for another value. I need to do this in 2 steps because the variable name (MI, CHF, CVD, etc.) is important. However, when
4. Here is what I have done so far, within 2 %do loops that run from 1 to &i and &j:
%let diagname = &%scan(&list_cci.,&i.);
%put &diagname; /*gives me e.g. &MI */
%let var=%scan(&diagname,&j.); /*--->here I expect it would scan the MI list, because &MI is put in the %scan function*/
%put &var; /* but all I get is the jth value from the &list_cci list... even though %put &diagname; gives me &MI!*/
Any ideas why it would scan the first list when I ask to basically %scan(&MI,&j.)? Any other idea how I could solve this?