BookmarkSubscribeRSS Feed
Zizie
Calcite | Level 5

%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);

7 REPLIES 7
Shmuel
Garnet | Level 18

What do you mean by "unsuccessful" ?

Pleas post the log. What error messages are there ?

Zizie
Calcite | Level 5
below is the log

ERROR: Physical file does not exist, I:\CRMD\Vintage analysis\Core Banking
Data\text
data\DEVIATION\Deviation_Tracking_as_at_20190731.txt.
ERROR: Import unsuccessful. See SAS Log for details.
NOTE: The SAS System stopped processing this step because of errors.
NOTE: PROCEDURE IMPORT used (Total process time):
real time 0.06 seconds
cpu time 0.04 seconds

Kurt_Bremser
Super User

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.

Kurt_Bremser
Super User

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.

Shmuel
Garnet | Level 18

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);
Shmuel
Garnet | Level 18

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.

 

 

ballardw
Super User

@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.