Hello all,
I am trying to create a new variable which is a combination of a text variable and a numeric variable.
for example:
The observation of the text variable is "abrt"
The observation of the first numeric variable is "03"
The observation of the second numeric variable is "2014"
I want that the observation of the new variable will be "abrt032014".
What is the simplest code for that?
Thank you,
Lior
@lioradam wrote:
Hello all,
I am trying to create a new variable which is a combination of a text variable and a numeric variable.
for example:
The observation of the text variable is "abrt"
The observation of the first numeric variable is "03"
The observation of the second numeric variable is "2014"
Do you mean "the value of ..." ???
If so, here is data step code to use:
length newvariable $ 20;
newvariable = cats(textvariable,firstnumericvariable,secondnumericvariable);
probably also best to give the new variable a length, I gave it 20 characters, but you may need more or fewer, depending on your data.
@lioradam wrote:
Hello all,
I am trying to create a new variable which is a combination of a text variable and a numeric variable.
for example:
The observation of the text variable is "abrt"
The observation of the first numeric variable is "03"
The observation of the second numeric variable is "2014"
Do you mean "the value of ..." ???
If so, here is data step code to use:
length newvariable $ 20;
newvariable = cats(textvariable,firstnumericvariable,secondnumericvariable);
probably also best to give the new variable a length, I gave it 20 characters, but you may need more or fewer, depending on your data.
Thank you very much.
This is the code I needed.
Regards,
Lior
@lioradam you should not mark your own "Thank you" message as the correct answer. You should mark the correct answer as the correct answer.
Sorry, I didn't notice that I marked the wrong message.
Now it is corrected.
Thanks again,
Lior
Hello @lioradam,
Glad to see that Paige Miller's solution worked for you. Then it would be fair and help later readers if you marked his helpful reply as the accepted solution, not your own "thank you" post. Could you please change that? It's very easy: Select his post as the solution after clicking "Not the Solution" in the option menu (see icon below) of the current solution.
Thank you for the explanation of how to correct it.
Regards,
Lior
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.