BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Gil_
Quartz | Level 8
Hi I have a text file coming in with a date
Report 2018-04-01.csv
Since that file date will change base on when report is run
I need to import today date file. Report 2018-04-02.csv
I was trying a proc import out= report
Datafile ="h:\ report &sysdate.csv"
Dbms= Csv replace;
Getnames=yes;
Datarows=2;
Run;
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

I would be very leery of letting an automated process with Proc Import read my data. As a minimum you should add the guessingrows=max option to have the best chance of consistent data.

Proc Import has to guess at lengths and types of variables and depending on the actual contents the types and lengths may change between files read.

I would suggest reading one file with import, go to the log and extract the data step generated and edit that code. Use the same code to read all of the files just changing input file names and output data set names.

 

If you go to combine data and get warnings or errors about mismatched data types or truncated character variables don't say you haven't been warned.

View solution in original post

2 REPLIES 2
Tom
Super User Tom
Super User

You should be able to create a macro variable with today's date in that format.

%let today=%sysfunc(today(),yymmddd10);

And then use the macro variable in the filename.

Datafile ="h:\report &today..csv"

Make sure to have a "extra" period. The first one will be used by macro processor to indicate the end of the macro variable name and the second one will become part of the generated filename.

You could just put the macro function call directly into the string, that will eliminate the need for the macro variable and the extra period.

Datafile ="h:\report %sysfunc(today(),yymmddd10).csv"
ballardw
Super User

I would be very leery of letting an automated process with Proc Import read my data. As a minimum you should add the guessingrows=max option to have the best chance of consistent data.

Proc Import has to guess at lengths and types of variables and depending on the actual contents the types and lengths may change between files read.

I would suggest reading one file with import, go to the log and extract the data step generated and edit that code. Use the same code to read all of the files just changing input file names and output data set names.

 

If you go to combine data and get warnings or errors about mismatched data types or truncated character variables don't say you haven't been warned.

sas-innovate-2024.png

 

Time is running out to save with the early bird rate. Register by Friday, March 1 for just $695 - $100 off the standard rate.

 

Check out the agenda and get ready for a jam-packed event featuring workshops, super demos, breakout sessions, roundtables, inspiring keynotes and incredible networking events. 

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 2 replies
  • 2372 views
  • 0 likes
  • 3 in conversation