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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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