【问题标题】:How to maually input data in SAS EG如何在 SAS EG 中手动输入数据
【发布时间】:2020-06-11 10:09:59
【问题描述】:

刚开始学习 SAS,正在阅读一本使用以下代码创建表的教科书。

Data travel;
    input City $ 1-9 Nights 11 LandCost 13-16 NumberOfEvents 18
          EventDescription $ 20-36 TourGuide $ 38-45
          BackUpGuide $ 47-54;
datalines;
Rome        3 750   7 4 M, 3 G                  D’Amico Torres
Paris       8 1680  6 5 M, 1 other              Lucas Lucas
London      6 1230  5 3 M, 2 G                  Wilson Lucas
New York    6 .     8 5 M, 1 G, 2 other         Lucas D’Amico
Madrid      3 370   5 3 M, 2 other              Torres D’Amico
Amsterdam   4 580   6 3 M, 3 G                  Vandever
;
Run;

这本书给出了预期的输出:

但是,当我运行程序时,它给了我以下信息

如何解决这个问题?

【问题讨论】:

    标签: sas enterprise-guide


    【解决方案1】:

    您的列指针不正确。看看这对你有没有帮助

    Data travel;
        input City $ 1-9 Nights 11 LandCost 13-16 NumberOfEvents 18
              EventDescription $ 20-36 TourGuide $ 38-45
              BackUpGuide $ 47-54;
    datalines;
    Rome      3 750  7 4 M, 3 G          D’Amico  Torres 
    Paris     8 1680 6 5 M, 1 other      Lucas    Lucas  
    London    6 1230 5 3 M, 2 G          Wilson   Lucas  
    New York  6 .    8 5 M, 1 G, 2 other Lucas    D’Amico
    Madrid    3 370  5 3 M, 2 other      Torres   D’Amico
    Amsterdam 4 580  6 3 M, 3 G          Vandever        
    ;
    Run;
    

    【讨论】:

      【解决方案2】:

      你自己是怎么输入数据线的?

      如果您使用制表位设置为 4 的编辑器键入它们,并且在键入数据行期间使用了 一些 制表符,则这些停止可能导致数据与样本不对齐代码。

      如果您复制粘贴,则可能源具有标签,并且编辑器将标签扩展为到达制表位的空格。

      无论如何,添加“标尺”注释行可以帮助您了解需要对代码或数据行进行哪些调整。

      Data travel;
          input City $ 1-9 Nights 11 LandCost 13-16 NumberOfEvents 18
                EventDescription $ 20-36 TourGuide $ 38-45
                BackUpGuide $ 47-54;
      datalines;
      Rome        3 750   7 4 M, 3 G                  D’Amico Torres
      Paris       8 1680  6 5 M, 1 other              Lucas Lucas
      London      6 1230  5 3 M, 2 G                  Wilson Lucas
      New York    6 .     8 5 M, 1 G, 2 other         Lucas D’Amico
      Madrid      3 370   5 3 M, 2 other              Torres D’Amico
      Amsterdam   4 580   6 3 M, 3 G                  Vandever
      ;
      *234567890123456789012345678901234567890123456789012345678901234567890123
      *        1         2         3         4         5         6         7
      *   T   T   T   T   T   T   T   T   T   T   T   T   T   T   T   T   T   T  cursor position after tab hit
      ;
      

      <NOSTALGIA>

      有些日子我怀念程序编辑器和行命令,例如 COLS

      SAS 文档似乎正在摆脱程序编辑器文档,就像一个尴尬的成年人可能会对他们十几岁时的糟糕发型图片所做的那样。

      祝你在 documentation.sas.com 上找到 The COLS line command displays a special line that indicates the column numbers across the Program Editor window. 好运,我找不到。

      </NOSTALGIA>

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-04-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多