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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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.

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