BookmarkSubscribeRSS Feed
PoulRavn
Obsidian | Level 7

Hi, this may sound strange as a strange thing to want to do, but when I use Import Data from the EG (6.1) menu, I can created an import step for a file (eg. a CSV file) that as a number as the first 'character' in the name, for instance 2016_07_26_mycsv.csv. This gets imported allright and a SAS dataset is created in the work folder with the same name, also including the first 'character', here a '2'.  But this dataset cannot be referenced by its name, at least not in any way I know of. So that is my question: How do I handle this?

 

Sometimes I have succesfully renamed the dataset manually in the explorer window, but strangely enough this not always allowed from EG61. I cannot see the pattern in when it is allowed and not and would like to have a more stable way of handling this.

 

Thanks in advance

Regards

Poul Ravn Sørensen

2 REPLIES 2
Reeza
Super User

Don't allow SAS to create names with numbers at the start. 

The first one has the standard SAS restrictions, the second option which seems to be the default in EG allows the naming convention you see. 

Options validvarname = v7;

Options validvarname = Any;

You can reference the dataset using a name literal, quotes and a N afterwards. 

 

'2016_07_26mycsv.csv'n 

 

 

RW9
Diamond | Level 26 RW9
Diamond | Level 26

@Reeza has given you a good explanation.  I would just add that this is another good example of why not to keep "data" in table names/column names.  Table names and variable names are for programming purpose - they are not to store data in.  It makes your life much harder if you are trying to work out what datasetnames are, what column names are.  Have a read where the "data" in the filename is stored to the dataset, and have one dataset for all the data.

 

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

Creating Custom Steps in SAS Studio

Check out this tutorial series to learn how to build your own steps in SAS Studio.

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
  • 10457 views
  • 1 like
  • 3 in conversation