全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1439 4
2014-02-27
data teng.narparks2 ;
infile 'C:\Users\Administrator\codes_sas\Parks.dat';
input name $1-21 type $ region $ museums camping;
run;
proc report nowindows missing headline;
column name type region museums camping facilities note;
define museums / sum ;
define camping / sum ;
define facilities / computed 'camping /and /museums';
compute facilities ;
facilities = museums.sum + camping.sum;
endcomp;
define note / computed ;
compute note / char length = 11;
if camping = 0 then note = 'no camping';   书上写的是camping.sum = 0 ????
endcomp;
title 'addsdf3wrfdefds';
run;

按照书上写的camping.sum= o的话,我最后得到结果note是正常的,但是写成if camping = 0的话,输出结果在note 一行就全变成了 no camping。。想请教下高手,为什么会成这样?在report过程中,是不能利用源数据来进行if逻辑判断呢??

数据是这样的

name

type

region

museums

camping

Dinosaur

NM

West

2

6

Ellis Island

NM

East

1

0

Everglades

NP

East

5

2

Grand Canyon

NP

West

5

3

Great Smoky Mountains

NP

East

3

10

Hawaii Volcanoes

NP

West

2

2

Lava Beds

NM

West

1

1

Statue of Liberty

NM

East

1

0

Theodore Roosevelt

NP

 

2

2

Yellowstone

NP

West

9

11

Yosemite

NP

West

2

13


二维码

扫码加我 拉你入群

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

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

全部回复
2014-3-1 12:32:53
Did you try if camping=2,   what are the results?
二维码

扫码加我 拉你入群

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

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

2014-3-1 13:02:00
TITLE "Conditional LINE statement processing for null lines of output";         
PROC REPORT NOWD DATA=sashelp.class;                                             
   COLUMN  Name Sex Age Height Weight;  
   DEFINE  Name / DISPLAY FORMAT= $8. WIDTH=8 LEFT "Name" ;      
   DEFINE  Sex / DISPLAY FORMAT= $1. WIDTH=7 LEFT "Gender" ;      
   DEFINE  Age / ORDER FORMAT= BEST9. WIDTH=9 RIGHT "Age" ;      
   DEFINE  Height / SUM FORMAT= BEST9. WIDTH=9 RIGHT "Height" ;   
   DEFINE  Weight / SUM FORMAT= BEST9. WIDTH=9 RIGHT "Weight";
   COMPUTE AFTER age;                                                               
      LENGTH text $ 50;                                                               
      IF age=15 THEN DO;                                                               
         text = 'for age=15 only';                                                     
         num=50;                                                                       
      END;                                                                             
      ELSE DO;                                                                        
         text = "";                                                                    
         num=0;                                                                        
      END;                                                                             
      LINE text $VARYING. num ;                                                      
   ENDCOMP;                                                                        
RUN;
二维码

扫码加我 拉你入群

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

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

2014-3-1 13:02:48
Compare yours with the above code
二维码

扫码加我 拉你入群

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

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

2014-3-1 15:11:40
irisbird 发表于 2014-3-1 12:32
Did you try if camping=2,   what are the results?
thank you for your reply.
I use the 2 for camping, but the result  also didn't satisfied.
I think it is not the value problem, it needs to dig the process of the REPORT procedure .
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

扫码加好友,拉您进群
各岗位、行业、专业交流群