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-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 3 replies
  • 420 views
  • 1 like
  • 3 in conversation