I simply want to copy the values from one variable onto the end of the values from another variable. I have some sample data:
time_frame var1
100days 293
6months 651
1year 307
And I want the end result to be
time_frame var1
100days293 293
6months651 651
1year307 307
Is there a way that I can input a hyphen or an underscore in between the time_frame and var1 values using the cats function?
Such as 6months_651?
If you want to insert some kind of delimiter, look at the catx() function. It does exactly that.
You can also do
cats(string1,'_',string2)
CATX() instead of CATT().
@bignate1030 wrote:
Is there a way that I can input a hyphen or an underscore in between the time_frame and var1 values using the cats function?
Such as 6months_651?
What is the defined length of your Time_frame variable? Is it going to be long enough to add on the entire value of var1?
If the defined length is less than 10 then you can't add anything onto 100days (7 characters) and would need to create a new variable as adding 3 more characters means you need 10 characters to hold the value.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.