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.;

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

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