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
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!
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.