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 😃
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.