Dear Stata Users
I have a string variable IssueCode. My aim is to end up with left 12 characters of this variable, for example 512KR7017170002 should become KR7017170002.
I am aware of substr function but my problem is that not all variables have the same amount of characters, I have variables such as 30KR7005560008, 507KYG5307W1015. But all I need is to take 12 left characters...
I have tried the following code but it does not work...
gen IssueCode2=substr( IssueCode ,-1, - 12)
What is the way around it?
Thank you.
I have a string variable IssueCode. My aim is to end up with left 12 characters of this variable, for example 512KR7017170002 should become KR7017170002.
I am aware of substr function but my problem is that not all variables have the same amount of characters, I have variables such as 30KR7005560008, 507KYG5307W1015. But all I need is to take 12 left characters...
I have tried the following code but it does not work...
gen IssueCode2=substr( IssueCode ,-1, - 12)
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input str16 IssueCode float(Price date) "7KR7200880003" 13450 20269 "1058KR7006890008" 6150 20269 "504KR7007570005" 77100 20269 "30KR7005560008" . 20269 "507KYG5307W1015" . . end format %tdNN/DD/CCYY date
What is the way around it?
Thank you.
Comment