楼主: springlilac
6807 3

[SAS] 请教一个 data input statement [推广有奖]

  • 0关注
  • 0粉丝

高中生

90%

还不是VIP/贵宾

-

威望
0 级
论坛币
67 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
967 点
帖子
25
精华
0
在线时间
44 小时
注册时间
2008-1-31
最后登录
2019-1-31

楼主
springlilac 发表于 2009-6-8 21:30:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
<b><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><p>请问下面程序 datalines 里.k&nbsp; .A &nbsp;是什么用法。为什么 log 没有 error?</p><p>谢谢!</p><p></p><p>data<font face="Courier New" size="2"><font face="Courier New" size="2"> statepop;<p><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">input</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2"> State $ citypop_80 citypop_90 <p>Noncitypop_80 Noncitypop_90 Region @@;</p></font></font></p></font></font></p></font></font></font></b><font face="Courier New" size="2"><font face="Courier New" size="2"> statepop;<p><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">input</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2"> State $ citypop_80 citypop_90 <p>Noncitypop_80 Noncitypop_90 Region @@;</p></font></font></p></font></font><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">input</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2"> State $ citypop_80 citypop_90 <p>Noncitypop_80 Noncitypop_90 Region @@;</p></font></font><font face="Courier New" size="2"><font face="Courier New" size="2"><p><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">datalines</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2">;<p>ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1</p><p>NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1</p><p>;</p></font></font></p></font></font><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">datalines</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2">;<p>ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1</p><p>NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1</p><p>;</p></font></font><b><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><p>proc<font face="Courier New" size="2"><font face="Courier New" size="2">
                                                        </font></font><b><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2">print</font></font></font></b><font face="Courier New" size="2"><font face="Courier New" size="2">
                                                        </font></font><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">data</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2">=statepop;</font></font></p></font></font></font></b><font face="Courier New" size="2"><font face="Courier New" size="2">
                </font></font><b><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2">print</font></font></font></b><font face="Courier New" size="2"><font face="Courier New" size="2">
                </font></font><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2"><font face="Courier New" color="#0000ff" size="2">data</font></font></font><font face="Courier New" size="2"><font face="Courier New" size="2">=statepop;</font></font><b><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><font face="Courier New" color="#000080" size="2"><p>run<font face="Courier New" size="2"><font face="Courier New" size="2">;</font></font></p></font></font></font></b><font face="Courier New" size="2"><font face="Courier New" size="2">;</font></font>
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:statement Statemen Statem State Input Data statement Input

回帖推荐

yongyitian 发表于3楼  查看完整内容

I guess it is way to assign a missing value for numerical data.  Therefore, missing numbers can be easily identified.  See the following log and printed results.data statepop; input State $ citypop_80 citypop_90 Noncitypop_80 Noncitypop_90 Region @@;datalines; ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1;data test ;  set stat ...

本帖被以下文库推荐

沙发
rdzr 发表于 2009-6-9 08:52:00
<p>LZ,偶运行了一下你的代码,看错误提示,不知你的LOG里为何没有?</p><p></p><p>NOTE: SAS initialization used:<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 6.75 seconds<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.42 seconds</p><p>1&nbsp;&nbsp;&nbsp; data statepop;<br/>2<br/>3&nbsp;&nbsp;&nbsp; input State $ citypop_80 citypop_90<br/>4<br/>5&nbsp;&nbsp;&nbsp; Noncitypop_80 Noncitypop_90 Region @@;<br/>6<br/>7<br/>8<br/><font color="#bb4444"><strong>9&nbsp;&nbsp;&nbsp; statepop;<br/>&nbsp;&nbsp;&nbsp;&nbsp; --------<br/>&nbsp;&nbsp;&nbsp;&nbsp; 180<br/>ERROR 180-322: Statement is not valid or it is used out of proper order.</strong></font></p><p>10&nbsp;&nbsp; input State $ citypop_80 citypop_90<br/>11<br/>12&nbsp;&nbsp; Noncitypop_80 Noncitypop_90 Region @@;<br/>13<br/>14<br/>15&nbsp;&nbsp; input State $ citypop_80 citypop_90<br/>16&nbsp;&nbsp; Noncitypop_80 Noncitypop_90 Region @@;<br/>17<br/>18&nbsp;&nbsp; datalines;</p><p>NOTE: The SAS System stopped processing this step because of errors.<br/><font color="#5ea25e"><strong>WARNING: The data set WORK.STATEPOP may be incomplete.&nbsp; When this step was stopped there were 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; observations and 6 variables.</strong></font><br/>NOTE: DATA statement used (Total process time):<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.09 seconds<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.04 seconds</p><p>24&nbsp;&nbsp; ;</p><p><br/>25<br/>26<br/><font color="#b3614d"><strong>27&nbsp;&nbsp; datalines;<br/>&nbsp;&nbsp;&nbsp;&nbsp; ---------<br/>&nbsp;&nbsp;&nbsp;&nbsp; 180</strong></font></p><p><font color="#b3614d"><strong>ERROR 180-322: Statement is not valid or it is used out of proper order.</strong></font></p><p>28&nbsp;&nbsp; ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;<font color="#aa5555"><strong> --<br/>&nbsp;&nbsp;&nbsp;&nbsp; 180<br/>ERROR 180-322: Statement is not valid or it is used out of proper order.</strong></font></p><p>29<br/>30&nbsp;&nbsp; NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1<br/>31<br/>32&nbsp;&nbsp; ;</p><p>33<br/>34&nbsp;&nbsp; proc print data=statepop;<br/>35<br/>36&nbsp;&nbsp; print data=statepop;<br/>37&nbsp;&nbsp; run;</p><p>NOTE: No observations in data set WORK.STATEPOP.<br/>NOTE: PROCEDURE PRINT used (Total process time):<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.07 seconds<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00 seconds</p><p><br/>38<br/>39&nbsp;&nbsp; ;</p><p></p><p>偶把你的程序 改了一下:</p><p>data statepop;</p><p>input State $ citypop_80 citypop_90 </p><p>Noncitypop_80 Noncitypop_90 Region @@;</p><p>cards;<br/>ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1</p><p>NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1</p><p>;<br/>proc print data=statepop;<br/>run;</p><p></p><p>下去是运行的 Log,注意,一切OK!</p><p>84&nbsp;&nbsp; data statepop;<br/>85<br/>86&nbsp;&nbsp; input State $ citypop_80 citypop_90<br/>87<br/>88&nbsp;&nbsp; Noncitypop_80 Noncitypop_90 Region @@;<br/>89<br/>90&nbsp;&nbsp; cards;</p><p>NOTE: SAS went to a new line when INPUT statement reached past the end of a line.<br/>NOTE: The data set WORK.STATEPOP has 4 observations and 6 variables.<br/>NOTE: DATA statement used (Total process time):<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00 seconds<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.00 seconds</p><p><br/>95&nbsp;&nbsp; ;<br/>96&nbsp;&nbsp; proc print data=statepop;<br/>97&nbsp;&nbsp; run;</p><p>NOTE: There were 4 observations read from the data set WORK.STATEPOP.<br/>NOTE: PROCEDURE PRINT used (Total process time):<br/>&nbsp;&n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414&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.475&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; NJ&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7.365&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 7.730&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1<br/></p><p></p><p></p>

藤椅
yongyitian 发表于 2009-6-9 12:04:00
<p>I guess it is way to assign a missing value for numerical data.&nbsp; Therefore, missing numbers can be easily identified.&nbsp; See the following log and printed results.</p><p>data statepop; <br/>input State $ citypop_80 citypop_90 <br/>Noncitypop_80 Noncitypop_90 Region @@;<br/>datalines; <br/>ME .405 .443 .721 .785 1 NH .535 .659 .386 .450 1<br/>NY 16.144 16.515 1.414 1.475 1 NJ 7.365 7.730 .k .A 1<br/>;<br/>data test ;<br/>&nbsp; set statepop;<br/>&nbsp; Noncity8090 = noncitypop_80 + noncitypop_90;<br/>&nbsp; keep noncitypop_80 noncitypop_90 noncity8090;<br/>run;</p><p>NOTE: <font color="#000000" style="BACKGROUND-COLOR: #ffff00;">Missing values were generated</font> as a result of performing an operation on missing values.<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Each place is given by: (Number of times) at (Line):(Column).<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1 at 76:31<br/>NOTE: There were 4 observations read from the data set WORK.STATEPOP.<br/>NOTE: The data set WORK.TEST has 4 observations and 3 variables.<br/>NOTE: DATA statement used (Total process time):<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; real time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.01 seconds<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; cpu time&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.01 seconds</p><p>proc print data=test; run; </p><p>Obs&nbsp; Noncitypop_80&nbsp; Noncitypop_90&nbsp;&nbsp;&nbsp; Noncity8090<br/>1&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.721&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.785&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.506<br/>2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.386&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.450&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 0.836<br/>3&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.414&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 1.475&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 2.889<br/>4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<font style="BACKGROUND-COLOR: #ffff00;"> K&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;.</font></p>
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

总评分: 经验 + 3  论坛币 + 3   查看全部评分

板凳
springlilac 发表于 2009-6-9 21:45:00
Thank you for detailed illustration. I think what you said does make sense. Appreciate it.

您需要登录后才可以回帖 登录 | 我要注册

客服
GMT+8, 2026-12-5 01:10