Hi all. Say I have a data set with these variables.
ID varA varB varAtext footnote2
1 12 34 12 * means caution in interpreting
I want to add a "*" to varAtext, so it will look like this:
ID varA varB varAtext footnote2
1 12 34 12* * means caution in interpreting
How do I do that?
In the original data set, there was another column, "Interpret_with_caution" and some rows had "YES", so I had code
if Intepret_With_Caution eq "YES" then Footnotes2 = "* means caution in interpreting";
And please, folks, no comments about why do I want to do this, why do I want to use this symbol, why do I use those words about caution, what are the rules for when to interpret with caution, and so on. Please, if you could just give me advise on how to do this, that would be great.
Thanks
The way you have worded this all you need to do is:
data want;
set have;
varAtext = cats(varAtext,'*');
run;
But I suspect there is something more complex you want to do but have not explained.
So perhaps VARATEXT is not defined long enough to handle the extra character?
Or perhaps there is some condition you need to test before adding the asterisk?
Or perhaps you want to create VARATEXT from VARA?
The way you have worded this all you need to do is:
data want;
set have;
varAtext = cats(varAtext,'*');
run;
But I suspect there is something more complex you want to do but have not explained.
So perhaps VARATEXT is not defined long enough to handle the extra character?
Or perhaps there is some condition you need to test before adding the asterisk?
Or perhaps you want to create VARATEXT from VARA?
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.