Can someone help me with a SAS code where a variable, MET, extract the numbers of the second variable, if one of the variables CODE_1-CODE_44 contains one of several codes (T1b, T4a, T3a) and that the first subsequent variable (of CODE_1-CODE_44) contains a 6-character code that starts with "LND" (LND001-LND200).
CODE_1 CODE_2 CODE_3 CODE_4 CODE_5 MET.1 MET.2
T1b LND022 C2a P4 T6B 22 .
T4a M4 C2a T4a LND020 20 .
T4a LND001 T1b LND044 LND032 1 44
Please post data in usable from (data step with datalines) and the expected result.
It is not clear what you want to create, maybe the MET-variables?
If that is the case, using compress to remove non-digits and input to create numbers seem to be a good choice.
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!
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.