BookmarkSubscribeRSS Feed
katie215
Calcite | Level 5

Hi-

I'm trying to work with a very large excel worksheet (it's got just over 600 variables/columns). When I import it as an excel sheet it gets cut-off (I now know the limit is 255). However when I converted the .xlsx file to CSV and then imported that I am able to get all of the variables to come into one SAS data set with no problem, however part way through the data set the variables were renamed with VAR213, VAR214, etc through the end.

Is there a way to get SAS to either import all of the excel sheet, or to keep all of the variable names in the import of the CSV file? Any help is greatly appreciated!!

Thanks,

Katie

2 REPLIES 2
ballardw
Super User

The most likely cause of the VAR213 type naming is either no column heading or very long column headings that match that of another column. SAS needs to have a unique handle to assign the variable name but if you have multiple columns labeled TOTAL, for example, then there is a problem as there can be only one variable named Total in a SAS data set.

You have a couple of choices. One is you can change the names of the variables using RENAME with Proc datasets.

If you are going to read multiple files in this format then it is worth modifying the datastep code generated by proc import to read the CSV file. You can copy the code from the log into the editor and modify the variable names on the informat, format and input statements.

Reeza
Super User

@BallardW suggestion of obtaining the proc import code and manually fixing is a good one.

If this is a one time process another suggestion would be import all variables as Var1-Var600 and then rename them.

Since your data is in Excel you could copy the first row to a new sheet, transposing it to obtain a list. Then use some concatenate functions to create the text required.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

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
  • 1406 views
  • 0 likes
  • 3 in conversation