Help using Base SAS procedures

Include date of file when importing

Accepted Solution Solved
Reply
Contributor
Posts: 42
Accepted Solution

Include date of file when importing

Hi SAS Community!

Is there a way to create a date variable when importing a .csv file ?

In other words, I want to import the file, and then additionally I want to create a new variable (that will be included in the data set) to display the date of when the file was created.

Do you guys have any suggestions ?

Thank you! Smiley HappySmiley Happy


Accepted Solutions
Solution
‎02-21-2014 05:55 AM
Super User
Posts: 5,424

Re: Include date of file when importing

FINFO() function will give you this information.

Data never sleeps

View solution in original post


All Replies
Contributor
Posts: 33

Re: Include date of file when importing

In a datastep after the input 'section' put  something like this

data load;

  infile 'path_file' <option>;

  put

    var1 ... varn

;

load_date=today();

run;

Work on the the datastep that i wrote because it's just an example

Contributor
Posts: 42

Re: Include date of file when importing

Thank you for the reply Barnipaz Smiley Wink .

But wouldn't this just give the present date ? I'm trying to create a variable that will show when this file (the excel file) was created, that is 2013/xx/xx.

Contributor
Posts: 33

Re: Include date of file when importing

If you know the date, for example February 3rd 2013

load_date='03feb2013'd;

If you get it from some place, for example from the file name, get it and put in the expression. There are function the take the file name.

I'l give you a tip, a very important one.

Study all the function, format, informat and, all macrovariable created by default. With them you can do almost everything in SAS.

Solution
‎02-21-2014 05:55 AM
Super User
Posts: 5,424

Re: Include date of file when importing

FINFO() function will give you this information.

Data never sleeps
Contributor
Posts: 42

Re: Include date of file when importing

Thank you for the help guys :smileygrin: :smileygrin: :smileygrin:.

Got the info of the file.

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 203 views
  • 0 likes
  • 3 in conversation