%macro dev(yymmdd);
proc import datafile = "I:\CRMD\Vintage analysis\Core Banking Data\text data\DEVIATION\Deviation_Tracking_as_at_&yymmdd1..txt"
out = DEV.Deviation_Tracking_&yymmdd1.
dbms = dlm
replace;
delimiter = '|';
run;
%mend;
%DEV(yymmdd1);
What do you mean by "unsuccessful" ?
Pleas post the log. What error messages are there ?
PLEASE use the {i} button for posting logs. Otherwise the horizontal formatting is lost, line breaks are inserted, and certain chracters and character sequences changed.
I guess you want to call your macro with a date. The string "yymmdd1" is not a date.
If yymmdd1 is a macro variable you created before, you forgot the ampersand.
Still, post the log, using the {i} button.
1) Pay attention to next error message:
ERROR: Physical file does not exist, I:\CRMD\Vintage analysis\Core Banking Data\text data\DEVIATION\Deviation_Tracking_as_at_20190731.txt.
why is file name broken into 3 lines ?
sas cannot find the file as it is written.
2) You can't call the macro as you wrote
%DEV(yymmdd1);
because yymmdd1 is not a date, as @Kurt_Bremser already posted.
If is a macro variable previously assigned then it should be:
%DEV(&yymmdd1);
1) I suggest you to change the code into
%let yymmdd1 = 20090807; /* adapt to desired date and format */
filename my_text "I:\CRMD\Vintage analysis\Core Banking Data\text data\DEVIATION\Deviation_Tracking_as_at_&yymmdd1..txt";
%macro dev(yymmdd);
proc import datafile = my_text
out = DEV.Deviation_Tracking_&yymmdd1.
dbms = dlm
replace;
delimiter = '|';
run;
%mend;
%DEV(&yymmdd1);
and check the log - is there same error for filename statement as before.
If possitive - fix it first.
@Zizie wrote:
%macro dev(yymmdd);
proc import datafile = "I:\CRMD\Vintage analysis\Core Banking Data\text data\DEVIATION\Deviation_Tracking_as_at_&yymmdd1..txt"
out = DEV.Deviation_Tracking_&yymmdd1.
dbms = dlm
replace;
delimiter = '|';
run;
%mend;
%DEV(yymmdd1);
It looks very suspicious that you define the macro to use a parameter YYMMDD but use the macro variable YYMMDD1. So it is quite likely that what you think you pass to the macro is not quite what is used.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.