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

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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