BookmarkSubscribeRSS Feed
Cruise
Ammonite | Level 13

Hi guys,

Please help take below code out of macro. 

I have to select certain disease cases from the data &file&year if found in the list &steps. Macros defined in the code below. I don't need double logics in macro as is now because I have a physical file prepped to replace &file&year now. I commented out the parts that I thought would not need. But it did not work out. I really have to get it out tonight. Crossing my fingers if anybody there for help. 

 

data icd(drop=diag rename=x=icd); set icd;
 format x $10.;
  diag=compress(diag,'.');
  diag_original=diag;
 x="[*]"||diag;
run;

proc sql noprint;
   select  icd
     into :steps separated by '|'
     from  icd;
quit;

%put &steps;

options compress=yes;
%let x=:Code_1 - :Code_24;

/*****************************************************************************************************************/;
libname red "C:\;
%macro loop(case); %global case1; %let case1=&case; %if &case=shape %then %let condition = &steps; proc datasets noprint; delete all_&type._other; run; /*%do year = 2014 %to 2017; */ /*%if &year >= 2016 %then */ /* %do; */ /* libname red "C:...";*/ /* %if &type=Int %then %let file=&type.;*/ /* %else;*/ /* %if &type=Out %then %let file=&type._direct;*/ /* %end; */ data momentary(compress=yes); set red.&file&year(where=(patient_county_code in (58,33,37))); icd_code = catx('*','*',Diag_Code, of Code:); if prxmatch("m/&condition/oi",icd_code) > 0; source="In"; run; proc append base=all_&type._other(compress=yes) data=momentary force; run; %end; %mend loop; /*%let type=Int;/* %loop(shape); /*%let type=Out;/
%loop(shape);*

 

3 REPLIES 3
Jagadishkatam
Amethyst | Level 16

you could pull the code from macro i.e., you could get the resolved code into the sas file with the following code. You should run the code with a macro call as below and a sample.sas file will be created in the path you specified.

filename mprint '~path/sample.sas';
options mfile mprint;
%loop(defects);
Thanks,
Jag
ballardw
Super User

"But it did not work out." is awful vague.

Are there errors in the log?: Post the code and log in a code box opened with the {i} to maintain formatting of error messages.

No output? Post any log in a code box.

Unexpected output? Provide input data in the form of a dataset, the actual results and the expected results. Data should be in the form of a data step. 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.

 

With macros run the code with Options Mprint Symbolgen Mlogic; before posting the log.

Cruise
Ammonite | Level 13
Studying basics of dynamic programming. Starting with this SUGI paper: http://support.sas.com/resources/papers/proceedings11/113-2011.pdf. Let me know if you suggest better resources for novice in macro like me. Thanks Ballardw.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 603 views
  • 1 like
  • 3 in conversation