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.

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