【问题标题】:How should I use stata's comment (///) command to break long code lines?我应该如何使用 stata 的注释 (///) 命令来打破长代码行?
【发布时间】:2015-09-09 08:32:48
【问题描述】:

我正在尝试运行以下带有注释分隔符 (///) 的 Stata 代码,以分解长行。尽管仔细阅读了手册,但我还是收到了一条错误消息。谁能告诉我我做错了什么?

谢谢,

史蒂夫

* SCHEXPR 3: SCHOOL-LEAVER DESTINATIONS

. label variable schexpr3 "School-leaver destinations"

. label define school_leaver 1 "Do nothing" 2 "Get more training or education" ///
  3 "Start work or look for a job" 4 "Start a family" 5 "Go overseas to study" ///
  6 "Go overseas to work" 7 "Go back to my country of birth" 8 "I have no plans"

. label values schexpr3 school_leaver


* SCHEXPR 4: TIMES ABSENT FROM SCHOOL

. label variable schexpr4 "Times absent from school"

. label define absent 1 "Never" 2 "Hardly ever" 3 "About once a week" 4 "Most days" ///
  5 "Every day"

. label values schexpr4 absent

【问题讨论】:

  • 你想把句子换到下一行吗?或者注释掉这条线?
  • 看看这个[将命令分成几行][1]:stackoverflow.com/questions/25299247/…
  • 您对最近三个帖子中的至少两个帖子有待处理的反馈。请参阅stackoverflow.com/help/someone-answers 当有人回答时该怎么做。即使是评论也比没有好。
  • 对作者个人资料的“声誉”部分的审查表明,参与 Stack Overflow 仅限于寻求帮助。尽管一再提出要求,但没有给出任何反馈,没有标记为已接受的答案,没有回答其他人的问题,也没有通过奖励那些提供帮助的人来提高作者的声誉。

标签: syntax command comments stata


【解决方案1】:

您收到什么错误信息?

代码运行良好:

. label define school_leaver 1 "Do nothing" 2 "Get more training or education" ///
>     3 "Start work or look for a job" 4 "Start a family" 5 "Go overseas to study" ///
>     6 "Go overseas to work" 7 "Go back to my country of birth" 8 "I have no plans"

. 
. label define absent 1 "Never" 2 "Hardly ever" 3 "About once a week" 4 "Most days" ///
>     5 "Every day"

. 
. label list
absent:
           1 Never
           2 Hardly ever
           3 About once a week
           4 Most days
           5 Every day
school_leaver:
           1 Do nothing
           2 Get more training or education
           3 Start work or look for a job
           4 Start a family
           5 Go overseas to study
           6 Go overseas to work
           7 Go back to my country of birth
           8 I have no plans

. 
end of do-file

【讨论】:

  • 谢谢。我是 Stata 的新手,对这个论坛也比较陌生。我认为我的问题可能是在执行部分文件时从我的 do 文件中剪切和粘贴代码。你以前遇到过这个问题吗?对于没有按预期回复,我最谦虚的道歉。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2017-11-24
  • 1970-01-01
  • 2018-05-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多