Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Removing third bracket from*a column which is numeric

    Hello everyone,

    How I can remove the third bracket from a column ( which is numeric and gives county code )? Do I need to use the regex code ?? or strltrim() command? I need to turn this column to numeric after removing the third column. So, if anyone share their expertise, that'd be very helpful!

    Code:
    ----------------------- copy starting from the next line -----------------------
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input str5 county
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    "001]"
    Last edited by Tariq Abdullah; 15 Apr 2022, 18:18.

  • #2
    Code:
    . destring county, ignore("]") generate(countynum)
    county: character ] removed; countynum generated as byte
    
    . format %03.0f countynum
    
    . list, clean abbreviate(12)
    
           county   countynum  
      1.     001]         001  
      2.     001]         001  
      3.     001]         001  
      4.     001]         001  
      5.     001]         001  
      6.     001]         001  
      7.     001]         001  
      8.     001]         001  
      9.     001]         001  
     10.     001]         001  
     11.     001]         001  
     12.     001]         001  
     13.     001]         001

    Comment


    • #3
      My sincerest apologies for getting back to you so late. Having been under the pressure of a few deadlines I somehow missed the opportunity to thank you for being so generous with your time and accurate suggestion which I was looking for. Much obliged !

      Comment

      Working...
      X