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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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