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



 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 1 reply
  • 315 views
  • 1 like
  • 2 in conversation