Announcement

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

  • .dct file has invalid varnames

    Hello Everyone,

    For context, I have a .dct file, exported from software that processes census data.
    Anent to this, I need to open and run the DO file in STATA, to check the data of the .dct file and outsheet it. In addition the DO file have lenghty variable names exceeds in 30 characters. You may refer to the images.
    As I run the scripts/command, I'm getting an error [variable name] invalid varname. Upon checking, STATA has a length limit in variable names which makes sense for the error.
    Hence, may I know if there's a way to push the execution of do file?

    Click image for larger version

Name:	Reading DCT File.png
Views:	1
Size:	8.5 KB
ID:	1759843


    Click image for larger version

Name:	dct file error.png
Views:	1
Size:	2.4 KB
ID:	1759844


  • #2
    Code:
    . di strlen("r13_z_other_source_of_electricity")
    33
    As you have realised there is a limit on the length of variable names in Stata (*), although it is 32 characters, not 30. There's no way round this; it's a hard limit.

    Perhaps the software that produced the file has an option to limit variable names. Otherwise it is difficult to know the best solution for you. Sometimes it is easiest just to fire up your favourite text editor and work at the problem directly. It's possible that the .dct file and .do file could be read into Stata as data -- string variables -- and edited that way, but without a sight of either file, that is just speculation. The text editor method doesn't require specialist knowledge; the other way needs more Stata skills.

    (*) https://www.statalist.org/forums/help#spelling applies.

    Comment

    Working...
    X