Announcement

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

  • convert strL to str#

    I tried to convert my key variable "name" from strL to str# to merge two datasets.
    However, the error code r(109) continues to occur.
    I've tried the following:

    . describe name

    storage display value
    variable name type format label variable label
    --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    name strL %-20s Name of owning party <party-name>


    . gen len=length(name)

    . summ len

    Variable | Obs Mean Std. Dev. Min Max
    -------------+---------------------------------------------------------
    len | 21,022,429 22.72522 9.84456 1 818

    . recast str818 name, force
    name: str818 invalid
    r(109);




    Also, I tried to compress command then I obtained

    . compress name
    (0 bytes saved)



    Does anyone have an idea to solve this problem?
    Thanks in advance



  • #2
    I don't know why your code doesn't work, but maybe try
    Code:
    generate str name_string = name
    replace name = ""
    compress name
    replace name = name_string
    drop name_string
    describe name

    Comment


    • #3
      Thank you for your answer! The recommended method failed due to a memory issues (cause my dataset contains 21,022,429 observations), instead I split the dataset in half and used recast command, and this time it worked without error.

      Comment

      Working...
      X