Announcement

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

  • Nonnumeric characters: "," and "%"

    The data on one of my variables is in percentage format with commas instead of dots. It seems like I need to get rid of them both. I try to destring, replacing with dots and converting to fractions but it doesn't work. Seems like they block each other; the "%" is stopping the "dpcomma" command and the "," is stopping the "percent" command.

    How can I solve this?

  • #2
    I can't reproduce this problem. The options (not commands) dpcomma and percent of the destring command are compatible.

    Code:
     
    . set obs 1
    obs was 0, now 1
    
    . gen test = "100,0%"
    
    . destring test, replace dpcomma percent
    test: characters % removed; replaced as byte
    
    . l
    
         +------+
         | test |
         |------|
      1. |    1 |
         +------+

    Comment


    • #3
      It worked. Thanks Nick. For some reason I separated the two options in my earlier try.

      Comment


      • #4
        This was also posted at http://www.talkstats.com/showthread....-and-quot-quot

        Please review the FAQ Advice to learn about our policy on cross-posting (and also our preference for full real names).

        Comment

        Working...
        X