SAS Programming

DATA Step, Macro, Functions and more
BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
geneshackman
Pyrite | Level 9

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

 

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

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?

View solution in original post

4 REPLIES 4
geneshackman
Pyrite | Level 9
Forgot to say, column varA is numeric, and varAtext is, obviously, string, or text.
Tom
Super User Tom
Super User

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?

geneshackman
Pyrite | Level 9
Tom. I think your method will work. I'll try it out and let you know. I was asking because I just wasn't sure about the "*" symbol because I wasn't sure whether SAS thought * meant "everything", the way excel does.
geneshackman
Pyrite | Level 9
Tom, I just tried your method. It works. Thank you very much!

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 2327 views
  • 1 like
  • 2 in conversation