Or alternatively, put this inside your macro:
data test(drop=s);
length lob $3 state $2;
do s = 'IMR IL', 'IMD IL', 'MMD MO', 'MMR MO', 'HMR IN', 'OMD OH', 'OAD OH';
lob = scan(s,1); state = scan(s,2);
output;
end;
run;
PG
Hi there,
* you write in a new sas file (let's say "data.sas") just your data step;
* then in your main sas file, where you make all manipulations you define a macro, for example;
%macro example();
%if (your condition in macro language) %then %INCLUDE "C:\...\...\data.sas";
%mend();
%example();
* it should work. i have tried it myself. of course nothing happens it the condition is not met.
* my full tryout code is:
data a;
input abc;
datalines;
1
2
3
;run;
proc sql noprint;
select abc into :abc separated by ' ' from a;
quit;
%put &abc;
%macro example();
%if &abc<=3 %then %INCLUDE "U:\Diane\BODACC\proc_coll_me.sas";
%mend();
%example();
Let me know if it works
Here is another option that works within a macro:
213 %macro monthly;
214 proc sql;
215 create table Lobs (Lob char(3), State char(2));
216 insert into Lobs
217 values ('IMR','IL')
218 values ('IMD','IL')
219 values ('MMD','MO')
220 values ('MMR','MO')
221 values ('HMR','IN')
222 values ('OMD','OH')
223 values ('OAD','OH');
224 quit;
225 %mend;
226 %monthly
NOTE: Table WORK.LOBS created, with 0 rows and 2 columns.
NOTE: 7 rows were inserted into WORK.LOBS.
NOTE: PROCEDURE SQL used (Total process time):
real time 0.00 seconds
cpu time 0.00 seconds
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.