BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
rgettys
Fluorite | Level 6

I am trying to duplicate a string column. 

in a data step, I am using

oldvar=newvar

but in the output table the newvar comes back as "."

 

Is there a special option to duplicate the characters in a string variable?

I am on SAS EG 7.13

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User

No, there is no extra step required. My guess is 'newvar' isn't actually new but is somehow defined in the dataset already as a numeric field. Ensure that the variable name is new or make sure the types match up when re-assigning data.

 

 

View solution in original post

2 REPLIES 2
Reeza
Super User

No, there is no extra step required. My guess is 'newvar' isn't actually new but is somehow defined in the dataset already as a numeric field. Ensure that the variable name is new or make sure the types match up when re-assigning data.

 

 

ballardw
Super User

To assign the value to the newvar you need to reverse the order:

 

newvar = oldvar;

 

The way you are doing it, using a variable that didn't exist before on the RIGHT side of = means that SAS created one to reference and since there wasn't any definition then the default is a numeric. And then without assigning a value it is initialized as missing.

SAS Innovate 2025: Save the Date

 SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!

Save the date!

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
  • 2 replies
  • 2642 views
  • 2 likes
  • 3 in conversation