1
votes

so I have a code like this

%let fdate=%sysfunc(today());
%put %sysfunc(putn(&fdate,MMDDYYD10.));
%let ydate=%eval(&fdate-1);
%put %sysfunc(putn(&ydate,MMDDYYD10.));

AND it seems working

127  %let fdate=%sysfunc(today());
128  %put %sysfunc(putn(&fdate,MMDDYYD10.));
SYMBOLGEN:  Macro variable FDATE resolves to 22152
08-25-2020
129  %let ydate=%eval(&fdate-1);
SYMBOLGEN:  Macro variable FDATE resolves to 22152
130  %put %sysfunc(putn(&ydate,MMDDYYD10.));
SYMBOLGEN:  Macro variable YDATE resolves to 22151
08-24-2020

but I am using like this.

proc import datafile = "S:csse_covid_19_daily_reports\&ydate..csv"
 out = T0824
 dbms = CSV
 REPLACE;

 GUESSINGROWS=100000;
 
run;

The error message is showing like this.

\csse_covid_19_daily_reports\22151.csv.
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.02 seconds
      cpu time            0.01 seconds

They converted back to 22151.

I have a file like this

enter image description here

so to pull this file in proc import, I want format like 8-24-2020. so I can get data from CSV to sas.

How can I fix the code?

Thanks

1
This may also be useful for you. You can process all at once dynamically if needed. This is better because once your input is specified it's faster and will ensure all are read in with the same types/formats so that you don't run into inconsistent data issues later on. communities.sas.com/t5/SAS-Communities-Library/…Reeza

1 Answers

1
votes

You need to use the same variable. In your testing you're using %SYSFUNC() but in your code you're not, so you're not comparing the same thing really.

Change your code to be:

 "S:csse_covid_19_daily_reports\%sysfunc(putn(&ydate.,MMDDYYD10.)).csv"

Or change your macro variable to be formatted. If you're using it in multiple locations then use %SYSFUNC() to control the display in different sitautions as warranted.