BookmarkSubscribeRSS Feed
almmotamedi
Obsidian | Level 7

I have imported several csv files into SAS separately using import data wizard. Now, I would like to merge (combine) them together. But, it seems that the format of one of the variables is not consistant in all the files. Could you please how do I fix this?, or what is wrong with my below code?

 

 

DATA SCOPES.ENTIRE_DATABASE_SCND_CONST;


SET WORK.SCOPESCALCULATIONS_SECONDARYCON1
( rename='COT00503.D_SRVY'n=COT00503_D_SRVY_str in=special )
WORK.SCOPESCALCULATIONS_SECONDARYCON2
( rename='COT00503.D_SRVY'n=COT00503_D_SRVY_str in=special )
WORK.SCOPESCALCULATIONS_SECONDARYCO49
( rename='COT00503.D_SRVY'n=COT00503_D_SRVY_str in=special )
WORK.SCOPESCALCULATIONS_SECONDARYCO54
( rename='COT00503.D_SRVY'n=COT00503_D_SRVY_str in=special )
WORK.SCOPESCALCULATIONS_SECONDARYCO64;


run;

3 REPLIES 3
ballardw
Super User

The problem is using the import wizard without noting differences. The wizard makes guesses about your data and using it for multiple files means multiple guesses. If one file has a character value in a column that doesn't appear in others then some files the field is treated as numeric and others as character.

 

If all of the files are of the same structure use the wizard once to generate datastep code and modify it to read all of the datasets with the same characteristics. Check the informats used to see if that makes sense for your data.

almmotamedi
Obsidian | Level 7

I think you did not get my question. I already imported all the files, and I just need to combine them. 

 

Yes, all files have exactly the same structure.

 

Thanks

Reeza
Super User

@ballardw is correct, fix the import/input first then you will have read all the files the same way and will not have this issue.

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