Announcement

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

  • From byte (with just missing values) to string

    Hello,

    I have a database, called "database1", in which variable "location" has format "byte" with just missing values. I want to append to "database1", another database, "database2". However, in this second database, the variable "location" is a string (str33). When I do the append, it gives me the following error: "variable location is byte in master but str33 in using data"

    I have tried to convert the variable "location" in "database1" to string in different ways:

    Code:
    decode location, gen(locationa)
    Error: location not labeled

    Code:
    recast str33 location, force
    Error: location: str33 invalid

    That two options does not work. I do not know what else to try. Another possible alternative is when I do the append, use force. However, I would like to explore if there is any way to convert variable "location" from "database1" to string to avoid to use force in the append.
    Last edited by Diego Malo; 01 Nov 2022, 11:32.

  • #2
    Code:
    help destring
    and look at the instructions for -tostring-

    Comment


    • #3
      It's a case for tostring

      Code:
      tostring location,  replace
      or

      Code:
      generate swap = strofreal(location)
      drop location
      rename swap location
      which is pretty much what tostring does any way (I was the original author).

      Comment


      • #4
        Thank you Both! I used tostring command, and it worked!

        Comment

        Working...
        X