Hi All,
I have two datasets which which have one column common to both the datasets.
Problem is that one variable which is common to both the dataset. Variable C is numeric in dataset A and character in Dataset B, i tried converting numeric to character using input function and then merge the two files into one master file but SAS datastep is not allowing it to convert it to character and keeps the variable numeric and merge fails because of that.
The merge can only happen if this variable C is character in both the datasets.
Anyone who faced similar problem, please share any suggestions that can help me merge dataset A and dataset B on variable C.
Tried using Proc sql too didn't work.
Any help is appreciated!
Thanks in advance!
RJ
/*set age to character*/ data probably_have (drop=_age); set sashelp.class (rename=(age=_age)); age=put(_age,$2.); run; /*set age to from character to numeric*/ data want (drop=_age); set probably_have (rename=(age=_age)); age=input(_age,8.); run;
You can only change a variable's type (and keep its name) by renaming the old variable.
Art, CEO, AnalystFinder.com
Post the code you tried.
Art, CEO, AnalystFinder.com
Post a copy of your log.
Art, CEO, AnalystFinder.com
Another thought, as I had understood you were changing the one variable to also be numeric. That would be a lot easier as, using character variables, both character variables have to be the same length.
Art, CEO, AnalystFinder.com
change the line:
IF a or b then OUTPUT= Jan.masterdata11;
to: IF a or b;
You could just get rid of the equal sign, but including output jan.masterdata11 would be redundant since you're only outputting one dataset.
Art, CEO, AnalystFinder.com
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.