BookmarkSubscribeRSS Feed
td1345
Fluorite | Level 6

Problem:

I have 1000s of xlsx sheets that I'm importing. However, they are poorly structured but contain a table that all start with a date-column with either 'date' or 'testdate' as column header (then the column contains dates). This keyword/header can be in various positions in excel (eg row 3 and column 4 or row 5 and column 3).

 

Solution:

Import xlsx file

create a variable with row-nr (_N_)

Identify row position of keyword ('date' or 'testdate')

import xlsx file at rownum = position given above to capture headers.

 

My problem lies in identifying the first occurrence of date or testdate searching all columns with unknown column names.

 

 

1 REPLY 1
SASKiwi
PROC Star

It would help if you could post an example of a sheet you are trying to import. Dummy data is fine if the original data is confidential.

 

I'd suggest using the XLSX engine in a SAS LIBNAME statement pointing at one of the Excel workbooks, then reading the required worksheet in using a SAS Data Step. 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 544 views
  • 0 likes
  • 2 in conversation