Building models with SAS Enterprise Miner, SAS Factory Miner, SAS Visual Data Mining and Machine Learning or just with programming

merging dataset with multiple variable length

Reply
Regular Contributor
Posts: 218

merging dataset with multiple variable length

Hi All,

Can someone tell me the most efficient way to merge two dataset with multiple variable length (either by variable or other common variable to be merged). Is there a macro that will solve this problem for any variable within the dataset?

I defined the output variable length as follows, and it still does not work.

data test

length Country$ 12.;

merge one two;

by Country;

run;

NOTE: my right table (two) by variable length is 12 and left table (one) by variable length is 10

Thanks,

Respected Advisor
Posts: 3,799

Re: merging dataset with multiple variable length

Are you sure it's an ERROR?

You just need to "fix" the lengths such that they match in both data sets or you could use the SAS system option to turn off the message and ignore this issue.

Perhaps someone has such a macro as you suggest or you can make your own.  Quite simple I should think.

Super Contributor
Posts: 337

Re: merging dataset with multiple variable length

Hey mlogan,

I am sure you can find a macro to do this on google.

And Art Carpenter's book has a macro for EVERYHTING... Carpenter's Complete Guide to the SAS® Macro Language, Second Edition

If you don't have a lot of variables just choose a length.

Data mymerged;

length country $25;

merge dataone datatwo;

by commonid;

run;

When you have a chance, take the programming 1 class and this certification: SAS Global Certification: SAS Certified Base Programmer

Good luck,

Miguel

Ask a Question
Discussion stats
  • 2 replies
  • 321 views
  • 0 likes
  • 3 in conversation