Hello, I realize that PROC SQL doesn't inherently have a do-loop function but I'm wondering if there's a way I can simulate it using macros or something else? I currently have a list of 53 three-letter combinations stored as a macro variable in my code. So it's basically "ABC", "ABB", "CBA", etc. I need to calculate % values for each one so that each one gets stored as its own variable. I can get this to work fine if I write 53 lines of code (one per each list value) but I'm wondering if there's a way I can take the values that I've stored in a macro variable and have the code write those repeated 53 lines for me to save space? I realize the final line would not have a comma at the end so I'd be fine with it writing 52 lines and then I'd include the 53rd manually. I've attempted various different %DO's, %DO_OVER, %ARRAY functions but can't seem to get it to do what I want. Any thoughts? Thanks. proc sql; create table TABLENAME as select GROUPVAR, count(*) as Total_Count, (sum(case when LISTVALUE="ABC" then 1 else 0 end) / calculated Total_Count as pct_ABC), /*first of 52 repeated items*/ . [Repeated 52 times for each 3-letter combo] . (sum(case when LISTVALUE="ZZZ" then 1 else 0 end) / calculated Total_Count as pct_ZZZ) /*final item from list*/ from ORIG_TABLE group by GROUPVAR quit;
... View more