06-03-2015 02:58 PM
I have a character variable with letters numbers and hyphen sign and would like to extract the letters and the first two digits before the FIRST hyphen sign and create a new variable identifying these people, here is an example
Variable ID looks like:
The new variable will look like
all your help will be appreciated
06-03-2015 03:11 PM
Do you have any that start with one letter: S12345-67? Or one numeral then the hyphen: 1-234-456? If so how are these processed?
06-03-2015 03:14 PM
The first two characters will be:
new_var = substr(variable,1,2)
I'm not sure what you are getting at with the hyphen. If the hyphen is important for another reason you might have to use something in addition to this like scan().
06-25-2015 12:51 PM
Thanks for your answers
ballardw: no, I don't have IDs starting with only one letter or one numeral
The IDs starting with SP indicate a type of affiliation (thanks Mark! I can identified these people now creating the new_var), those with two digits and then the hyphen have a different affiliation as those starting with numbers but with hyphen at the end like -01, -02 etc, but I still need to separate these latter two groups
Thanks again for your help