how do you merge two data sets and create an identifier between two common variables (changing a variable to numerical or one to character)
You should provide example data of the two data sets and what you expect as a result. Data is best in the form of a data step.
Note that if the variable in two or more data sets for Merge or Set with the same name has different types then SAS will throw an error and not allow any execution of the data set. You will need to either rename the variable so they don't have the same name or in a prior step go the dance to create a different data set with the proper type variable.
Here's an example of "fixing" a character variable that should have been numeric:
data have; input x $; datalines; 1223 456 ; run; data want; set have(rename=(x=oldx)); x=input(oldx,f5.); run;
The numeric to character case involves a PUT statement with the proper format.
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.