BookmarkSubscribeRSS Feed
tdegen
Calcite | Level 5

I have a data set we'll say is simply called "MyDataset".   Normally this would be saved as a file called "MyDataset.sas7bdat".   However, some automated program on the server (not SAS) moves older files into an archive appends dates to the file - so now my file is called: "MyDataset.01Dec2022.sas7bdat"

 

How can I read this file in SAS without renaming the file?   Third party ODBC connectors don't seem to have an issue, but I'm just trying to use windows sas.exe and I get all kinds of errors.

 

LibName myLib 'E:\Archive' ;

proc contents data =myLib.MyDataset.01Dec2022; 

run;

-or-

proc contents varnum data='E:\Archive\MyDataset.01Dec2022.sas7bdat';

run;



If I rename the file so the filename matches the dataset name, I have no issues.  How can I read the file without changing the file name?

2 REPLIES 2
ballardw
Super User

Normally dots are not accepted as part of a data set name because of other syntax, such as the LIBNAME.DATASET rules.

If you want to use those non-standard names then you set the option Validmemname=Extend to allow non-standard dataset names and then use a name literal, the name enclosed in quotes followed by an N.

options validmemname=extend;

proc contents data=mylib.'Mydataset.01Dec2022'n ;
run;
Kurt_Bremser
Super User

Two things come to my mind.

  • the automatic archiver should use an underline, not a dot, to separate the date. Underlines cause much less hassle
  • the date should be only digits in YMD order (YYYYMMDD). Makes handling such files much easier

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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