Hi all,
I have two variables with the same information, its just one has the missing characters for the other. How do I merge them together to fill in the blanks?
For example;
ParkingSpot Comments
1-11-21
1-12-22
1-13-23
I would like it to look like:
ParkingSpot
1-11-21
1-12-22
1-13-23
How do I achieve this outcome? CAT or Merge?
Thanks
Besides of coalescec() a simple condition would also do the job
if missing(parkingspot) then parkingspot=comments;
@EM_G wrote:
Hi all,
I have two variables with the same information, its just one has the missing characters for the other. How do I merge them together to fill in the blanks?
For example;
ParkingSpot Comments
1-11-21
1-12-22
1-13-23
I would like it to look like:
ParkingSpot
1-11-21
1-12-22
1-13-23
How do I achieve this outcome? CAT or Merge?
Thanks
Does "comments" ever hold a value you do not want in the "Parkingspot" variable? And are the variables the same type?
If the answers above are "no" to the first and "yes" to the second then
Data want; set have; parkingspot= coalescec(parkingspot, comments); run;
The Coalescec, and the similar for numeric values Coalesce, functions examine the list of values in quotes and returns the first non-missing value.
Merge is data set operation, not variables.
One of the CAT functions might work but if you ever have both variables with any values the result is likely to be a problem.
Besides of coalescec() a simple condition would also do the job
if missing(parkingspot) then parkingspot=comments;
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!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.
Select SAS Training centers are offering in-person courses. View upcoming courses for: