BookmarkSubscribeRSS Feed
dstevens32
Calcite | Level 5

I have 250 excel files of sec financial data that I am trying to stack into one master sheet of data. However, when I go to do this there is a discrepancy in variable types across the data. For example(hypothetical), column 3 will be the date filed and in some of the files it reads in as numeric and others it will read in as a character variable. This is causing issues whenever I goto stack the files. Any suggestions on what I should do?

2 REPLIES 2
Reeza
Super User
Convert your Excel files to CSV, read them in with the same data step, which allows you specify the variable types consistently.

If they're all in the same folder something like this code will convert all in batch.
https://gist.github.com/statgeek/878e585102c14e01581f55dbe972d27e


Kurt_Bremser
Super User

Concur with @Reeza 's suggestion. You will only be able to make this a stable process by eliminating the Excel file format as a transfer medium.

Save to CSV and read with a data step.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 2 replies
  • 515 views
  • 2 likes
  • 3 in conversation