I'm trying to replace only part of a value for one variable, so it matches to merge with another dataset based on this Facility ID. Don't worry about the contaminant or value variables, I just left them in there for the example. So, I want to be able to change the facility name from WP001574 to WP531574, from WP001575 to WP531575, and so on. I just need to replace part of the value. How can I do this? Thanks!
Have:
data contam;
input FacilityID FacilityName $ Contaminant $ Value;
datalines;
1 WP001574 a 5
2 WP001575 d 10
3 WP001576 b 2
4 WP002475 c 8
5 WP002476 e 30
6 WP003843 a 2
7 WP003843 a 5
8 WP003844 b 8
9 WP003845 c 20
10 WP003846 d 30
11 WP003847 e 55
;
run;
Want:
data contam;
input FacilityID FacilityName $ Contaminant $ Value;
datalines;
1 WP531574 a 5
2 WP531575 d 10
3 WP531576 b 2
4 WP532475 c 8
5 WP532476 e 30
6 WP533843 a 2
7 WP533843 a 5
8 WP533844 b 8
9 WP533845 c 20
10 WP533846 d 30
11 WP533847 e 55
;
run;
The SUBSTR function permits this:
substr(facilityName, 3, 2) = '35';
RTM: Function TRANSTRN
http://support.sas.com/documentation/cdl/en/lefunctionsref/69762/HTML/default/viewer.htm#n101a8jch5t...
Or for this specific job SUBSTR(left of 😃
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
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.