Here is my code:
data libname.file_combined;
set libname.file_a
libname.file_b;
run;
I tried to merge two files and got this error:
ERROR: Variable X has been defined as both character and numeric.
ERROR: Variable Y has been defined as both character and numeric.
ERROR: Variable Z has been defined as both character and numeric.
Variables X, Y and Z has cells that are either numeric or alpha-numeric. So my assumption is that I have to convert them to character. I ran this code I got an error: EXPECTING a FORMAT NAME. It looks like SAS doesn't like the 5.
data file_a (drop=a_variablex);
set file_a (rename=(variablex=a_variablex));
variablex=input(a_variablex,5);
run;
Any advice/help is appreciated!
Thanks!
When using a Format you need to have a period at the end.
Try
variablex= input(a_variablex,f5.);
You may have done this already, but it may be a good idea to run Proc Compare to see which data set has the numeric and which has the character versions of the variables in question.
When using a Format you need to have a period at the end.
Try
variablex= input(a_variablex,f5.);
You may have done this already, but it may be a good idea to run Proc Compare to see which data set has the numeric and which has the character versions of the variables in question.
I did a PROC COMPARE: file_a = $5. (character) and file_b=BEST 12. (num)
I ran this code and still got the same error (Variable has been definted as both character and numeric).
data file_b (drop=a_variablex);
set file_b (rename=(variablex=a_variablex));
variablex=input(a_variablex,$5.);
run;
Thoughts???
I would confirm that variablex is now a character variable. I suspect not. If not, try using variablex = put(a_variablex,f5.);
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.