BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Q1983
Lapis Lazuli | Level 10
data have;
id1 = 'uv223';
id2 = '';
mid = 'uv223';
new_id = put(id1,id2,mid,best12.);
run;

I have a file similar to the above.  There are three possibilities for the same ID reference.  I want to assign the variable value, in this case 'uv223' to a new character variable called new_id.  In one of the id's there is no value however the other two do have the same value.  So new_id should equal 'uv223'.  As you can see I attempted to do this with a put statement but received an error

1 ACCEPTED SOLUTION

Accepted Solutions
Reeza
Super User
data have;
id1 = 'uv223';
id2 = '';
mid = 'uv223';
new_id = coalescec(id1,id2,mid) ;
run;

PUT() converts types. 

What do you want to see as the output? My guess is you want the COALESCEC() function or possibly a CAT function.

 


@Q1983 wrote:
data have;
id1 = 'uv223';
id2 = '';
mid = 'uv223';
new_id = put(id1,id2,mid,best12.);
run;

I have a file similar to the above.  There are three possibilities for the same ID reference.  I want to assign the variable value, in this case 'uv223' to a new character variable called new_id.  In one of the id's there is no value however the other two do have the same value.  So new_id should equal 'uv223'.  As you can see I attempted to do this with a put statement but received an error



 

View solution in original post

1 REPLY 1
Reeza
Super User
data have;
id1 = 'uv223';
id2 = '';
mid = 'uv223';
new_id = coalescec(id1,id2,mid) ;
run;

PUT() converts types. 

What do you want to see as the output? My guess is you want the COALESCEC() function or possibly a CAT function.

 


@Q1983 wrote:
data have;
id1 = 'uv223';
id2 = '';
mid = 'uv223';
new_id = put(id1,id2,mid,best12.);
run;

I have a file similar to the above.  There are three possibilities for the same ID reference.  I want to assign the variable value, in this case 'uv223' to a new character variable called new_id.  In one of the id's there is no value however the other two do have the same value.  So new_id should equal 'uv223'.  As you can see I attempted to do this with a put statement but received an error



 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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
  • 1 reply
  • 580 views
  • 1 like
  • 2 in conversation