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

I will be importing an excel file using proc import.  The excel file is updated every month with a new tab for that month. (Ex: "06-16" as the tab name).  Is there a way to only import the tab that has the current month as the tab name?

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
PGStats
Opal | Level 21

... Or go directly for

 


proc import datafile="&sasforum\datasets\testdatetab.xlsx" out=test replace;
sheet="%sysfunc(putn(%sysfunc(today()),mmyyd5.))";
run;

if you don't need the sheet name for other purposes.

PG

View solution in original post

3 REPLIES 3
ballardw
Super User

This code will return the current date in MM-YY format:

%let tab = %sysfunc(putn(%sysfunc(today()),mmyyd5.));

 

Use "&tab" where you would reference the sheet name.

PGStats
Opal | Level 21

... Or go directly for

 


proc import datafile="&sasforum\datasets\testdatetab.xlsx" out=test replace;
sheet="%sysfunc(putn(%sysfunc(today()),mmyyd5.))";
run;

if you don't need the sheet name for other purposes.

PG
RW9
Diamond | Level 26 RW9
Diamond | Level 26

Or go down the correct route, build a data transfer agreement which both the sender and you agree to which details what data should be sent, what the strcuture of the data should be, also wether is will be cumulative or incremental, and fix the data transfer type using a proper data transfer file format - CSV, XML dataset etc.  That way you can write a simple datastep import to properly process the data into a useable format according to a documented process, and it is reproduceable.  Using Excel and proc import is the bigget method to failure and the reason why we see so many questions on here about messy data - it hasn't been processed correctly in the first place.

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