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

Hil folks,

 

I know that SAS can't handle datasets with more than 32 characters. But is there any way to identify it (are SAS datasets not DBMS tables) and change the name to any one below 32 characters using SAS programming? 

 

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

SAS will not make a SAS7BDAT file with a name like that. Someone must have made the file outside of SAS or renamed the file outside of SAS.

 

Just use operating system command to rename the file.   If it has not been disabled in your installation just call the operating system RENAME command (mv on Unix) to rename the file.  Then you can reference the file as a dataset.

data _null_;
  infile "mv table_name_user_big_name_table_table_table.sas7bdat table_name_user_big_name.sas7bdat" pipe;
  input;
  put _infile_;
run;
data want;
  set "table_name_user_big_name.sas7bdat";
run;
 

If Operating System command access is disbled SAS does have the FCOPY() function that will let you copy the file to a new file with a shorter name.  I don't think it has a file rename function, but perhaps there is one hiding in the grab bag of functions.

 

View solution in original post

7 REPLIES 7
ChrisNZ
Tourmaline | Level 20

Sorry this question is unclear to me. What data sets do you have and what outcome do you want?

MariaD
Barite | Level 11

Hi @ChrisNZ ,

 

Please, apologise me if my question was not clear. In our SAS environment, we find some SAS tables with names with more than 32 characters. For example: "table_name_user_big_name_table_table_table.sas7bdat". My question is, is there any way using SAS programming to change the name of this datasets to any one with less than 32 characters? For example the new name will be "table_name_user_big_name.sas7bdat". 

 

Regards, 

 

 

Tom
Super User Tom
Super User

SAS will not make a SAS7BDAT file with a name like that. Someone must have made the file outside of SAS or renamed the file outside of SAS.

 

Just use operating system command to rename the file.   If it has not been disabled in your installation just call the operating system RENAME command (mv on Unix) to rename the file.  Then you can reference the file as a dataset.

data _null_;
  infile "mv table_name_user_big_name_table_table_table.sas7bdat table_name_user_big_name.sas7bdat" pipe;
  input;
  put _infile_;
run;
data want;
  set "table_name_user_big_name.sas7bdat";
run;
 

If Operating System command access is disbled SAS does have the FCOPY() function that will let you copy the file to a new file with a shorter name.  I don't think it has a file rename function, but perhaps there is one hiding in the grab bag of functions.

 

MariaD
Barite | Level 11

Thanks @Tom , yes the users made outside SAS.

SASKiwi
PROC Star

When you try to create a SAS table with a name more than 32 characters long SAS will fail and not create it. Where do you see these long name SAS tables? By viewing folder contents with an OS command or some other way? It is very unlikely these are genuine SAS tables. You can always try renaming them to < 32 character long names using an OS command. Then try reading them in SAS.   

ChrisNZ
Tourmaline | Level 20

This becomes a question about system files then: how to list and rename files.

@Tom 's reply addresses the rename part, and there are many answers on this forum about ways to list files.

Very curious how you ended up with such long (and invalid) data set names?

 

MariaD
Barite | Level 11

Unfortunately, some users change SAS datasets name through SAS EG (accessing "File folder").

 

Regards, 

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 1338 views
  • 1 like
  • 4 in conversation