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

Hi,

 

Following my topic of yesterday:

https://communities.sas.com/t5/Base-SAS-Programming/proc-import-excel-sheet/m-p/390276#M93589

 

I don't have another choice than importing an excel sheet with column names as equals to the first row of my sheet.

The two major problems are:

- the first row can change from one sheet to another then the column names also

- some column names have spaces 😕

 

I can manage the first problem by looking for column names with sashelp.vcolumn

The second is more complex. I think I can, but it's an hard work because I need to use names in several ways, transposing, aggregating,...

 

Is there a way to replace all spaces by this: _ for all variables of a table (whatever they are) without naming them?

 

Thanks,

 

1 ACCEPTED SOLUTION
6 REPLIES 6
FP12
Obsidian | Level 7

Wooh you just saved my life, nothing less! Thanks.

I was trying to find a difficult solution and in one line you solve my problem...

I feel so stupid right now ^^

PeterClemmensen
Tourmaline | Level 20

Anytime, glad to help 🙂

Oligolas
Barite | Level 11

Hi,

 

when using proc import with getnames=yes SAS get rid of the spaces in the name and inserts underscore, so I don't get what's the problem here.

 

if sometimes your data contain the names in first row and sometimes not, you should try identify the sheets having names and those without and import separately.

 

If you want to automate the whole thing I think you have no other solution than importing the whole document twice, one time with yes and one time with no.

 

Without test data and approximation of the number of sheets/frequency it's difficult to say what's best.

________________________

- Cheers -

RW9
Diamond | Level 26 RW9
Diamond | Level 26

" but it's an hard work because" - the answer to this is because you are forced to use a very poor data source.  No matter what you do, or what you program, it will never be a stable efficient process if the input is not.  Whenever I get this scenario, after pushing back, then I resort to other methods, for instance:

"Well, due to the nature of the source, the programming will take X hours longer (costing xyz), and the ongoing cost per unit (i.e. import) would be xyz for maintenance"

Its amazong how things get changed when you lay it out like that.

FP12
Obsidian | Level 7

I don't deny it...

But the house values are to ask for better quality but find an alternative while waiting for it.

So as you say, I'm forced to use  poor quality 😞

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!

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.

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
  • 6 replies
  • 1197 views
  • 4 likes
  • 4 in conversation