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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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