Reputation: 3897
I have a bunch of SAS data sets with a seq number that I want to merge by. Unfortunately in some data sets the seq is numeric and in others it's character.
I get the following error:
ERROR: Variable seq has been defined as both character and numeric.
There are many tables being merged and finding the tables that are the culprits will be painstaking. Is it possible to force the seq to numeric in an efficient manner in the merge by statement across all tables?
Upvotes: 0
Views: 543
Reputation: 9569
You can create a view of each of the datasets where the merge variable is of type character, apply appropriate recode / drop / rename logic within the views, and then merge the views with your other datasets. If you need to do this for a large number of datasets you could write the logic as a simple macro and then loop over them.
Upvotes: 1
Reputation: 63424
No, there's no way to force it to numeric directly (nothing like putting a single length statement in or anything like that). You'll need to convert it to numeric on a dataset by dataset basis.
There are some ways you can do this that might do it without worrying about what type things are on a dataset by dataset basis. One is to create the recode from the dictionary.columns. Another is to write every dataset out to a text file and read them back in with a consistent input statement. A third is to use CATS to cast the variable to character and then read it back with input into a numeric.
Upvotes: 1