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
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
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
April 27 – 30 | Gaylord Texan | Grapevine, Texas
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!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.
Ready to level-up your skills? Choose your own adventure.