Announcement

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

  • error: r(498); variable X has leading or trailing blanks.

    Click image for larger version

Name:	image_35447.png
Views:	1
Size:	140.0 KB
ID:	1758335 Hello Forum Members,

    I am doing reshaping of my data and I kept the data as required format. My "j" matrix variable is "crop name" which is a string one. Although I specified string option in the command, still facing a problem like

    [reshape wide var1 var2 ..... varn, i(HHID) j(cropname) string
    variable cropname has leading or trailing blanks
    r(498);]



    Kind advice would be highly regraded.

    Thanks

  • #2
    The literal interpretation is that observations of the variable have spaces at the start, the end, or both. So you first need:

    Code:
    replace cropname= strtrim(cropname)
    However, the problem may be more complicated than this. Stata variable names cannot contain spaces anywhere and cannot start with anything other than a letter or an underscore. Allowable characters are letters, numbers, and underscores.

    Code:
    help naming conventions
    As usual, screenshots are not as helpful as you might think. If the above advice does not resolve your problem, please present a data example using the dataex command (see FAQ Advice #12 on these points).

    Comment


    • #3
      Hello Musau, Thank you for your kind response. I think I have committed some mistakes on the dataset. If I still face that issue I will do ask as you suggested. Thanks.

      Comment

      Working...
      X