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 2025: Call for Content

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!

Submit your idea!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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