BookmarkSubscribeRSS Feed
SAS_user_RG
Calcite | Level 5

Hello 

Can anyone offer an option for dealing with Excel files that contain merged rows as the Headers? I am using base SAS 9.4.

SAS_user_RG_1-1624484674637.png

 

The files I am working with are collected daily. I need to create a way to remove the merge and reformat the rows. 

Importing and deleting is not an option due to SAS reading the rows below the headers as text during the import.

 

I have a second issue, if anyone can offer an idea of how to deal with it. A different Excel file has the first row blank. 

 

SAS_user_RG_2-1624484967639.png

 

Is there a way to delete the first row without using the import function?

 

Thank for any help you can offer. 

 

 

 

1 REPLY 1
ballardw
Super User

Same solution for both:

 

If the purpose is to create SAS data sets you have two options but both pretty much involve data step code.

One is to save the files as CSV and write a data step to read the file. Your variable properties, like NAME, informat, length, format and label are set by you and the input reads the columns. The Infile statement pointing to the file will allow you to define which is the first row of data to read.

 

The other approach is to use a LIBNAME  excel to point to the source file, and use a data step to manipulate the data starting on a specific row. This has potential weakness because minor changes in the data content may require rewriting bits of the code.

If you are reading these every day the amount of time to do a "file save as" to CSV is well worth the time you might spend trying to fix other junk from "importing" Excel data.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 412 views
  • 1 like
  • 2 in conversation