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

i want to call the fill name from the local directory. my file name will be month.xlsx. month name will be to the current month filename.

How can i include in the proc import the dynamic filename.

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

@radha009 wrote:

i want to call the fill name from the local directory. my file name will be month.xlsx. month name will be to the current month filename.

How can i include in the proc import the dynamic filename.


So if you ran it now would you expect to find February.xlsx or March.xlsx

The easiest way seems to use a macro variable.

 

%let month = %sysfunc(today(), monname20.);
%put &month.;

View solution in original post

4 REPLIES 4
andreas_lds
Jade | Level 19

If sas is not running locally, you can't access local files.

radha009
Quartz | Level 8

my sas is running locally. i have full path in the Proc import data file. i have to change every month my script to the change the file name to generate a reprot.i am looking something that look for the filename from the folder.

andreas_lds
Jade | Level 19

Are you using display manager or enterprise guide? With EG you could add a prompt allowing you to select the file to import. The name can be computed if rules exist. If you just want the latest file in a folder, using cmd/powershell to get the filename is recommended, because, compared to a full-implementation in sas, less code is required. If you want / have to do it in sas have a look at the functions dopen, dnum, dread, fopen, finfo ...

Reeza
Super User

@radha009 wrote:

i want to call the fill name from the local directory. my file name will be month.xlsx. month name will be to the current month filename.

How can i include in the proc import the dynamic filename.


So if you ran it now would you expect to find February.xlsx or March.xlsx

The easiest way seems to use a macro variable.

 

%let month = %sysfunc(today(), monname20.);
%put &month.;

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1460 views
  • 0 likes
  • 3 in conversation