BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
mjheever
Obsidian | Level 7

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

1 ACCEPTED SOLUTION

Accepted Solutions
LinusH
Tourmaline | Level 20

FINFO() function will give you this information.

Data never sleeps

View solution in original post

5 REPLIES 5
Barnipaz
Obsidian | Level 7

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

mjheever
Obsidian | Level 7

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.

Barnipaz
Obsidian | Level 7

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.

LinusH
Tourmaline | Level 20

FINFO() function will give you this information.

Data never sleeps
mjheever
Obsidian | Level 7

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

Got the info of the file.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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