BookmarkSubscribeRSS Feed
John89
Calcite | Level 5
I have a job of appending 100s of excel sheets into one and reformatting, unfortunately some of the variable names length are greater than 32 and when I try reformat using ‘format ‘ ‘ n best12.’, the code shows a warning as uninitialised. When I try the same code in SAS EG it works perfectly, any suggestions?
2 REPLIES 2
Tom
Super User Tom
Super User

Variable names in SAS cannot be greater than 32 bytes long.

If your column headers in your Excel sheets are longer than 32 bytes then PROC IMPORT should convert them into unique names for you.  Note that it will process each sheet separately so you might have issues trying to combine them if they do not all have exactly the same column headers and content type.  

 

 

ballardw
Super User

@John89 wrote:
I have a job of appending 100s of excel sheets into one and reformatting, unfortunately some of the variable names length are greater than 32 and when I try reformat using ‘format ‘ ‘ n best12.’, the code shows a warning as uninitialised. When I try the same code in SAS EG it works perfectly, any suggestions?

Please show an exact statement as submitted and the message from Log. If you reference a variable that does not exist that is the typical message.

 

If your are running EG you often encounter settings used by a server that may not be in effect in a stand alone version of SAS involving naming literals. If you run this code:

proc options option=validvarname;run;

and get in the log

 

 VALIDVARNAME=V7   Specifies the rules for valid SAS variable names that can be created and
                   processed during a SAS session.

then use of name literals is not set. You could make that available using in your program

 

options validvarname=any;

and reset to the default with

 

options validvarname=V7;

when you no longer want to use name literals.

 

 

I would strongly suggest NOT using validvarname=Any as the sometimes way to long columns many users place in Excel become a pain to deal with. You might consider using the actual column headings as LABELS though.

 

 

If you want to set all of the numeric variables better would be: Format _numeric_ best12. ; However if you have dates, times or datetime values this would also set their formats.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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
  • 655 views
  • 5 likes
  • 3 in conversation