楼主: priis
1904 7

[有偿编程] 在SAS里面用loop进行data input,但运行出来结果很奇怪 [推广有奖]

  • 0关注
  • 0粉丝

已卖:1份资源

高中生

5%

还不是VIP/贵宾

-

威望
0
论坛币
39 个
通用积分
0
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
216 点
帖子
6
精华
0
在线时间
29 小时
注册时间
2014-11-14
最后登录
2019-11-15

楼主
priis 发表于 2015-11-8 04:15:15 |AI写论文
50论坛币
data如下:
78 70 79 78 77 78 69 72 73 75
79 76 66 80 76 78 68 77 71 77 83
78 76 70 72 75 72 76 73 72
66 66 74 64 69 67 70 75 70 68 69
64 72 65 66 70 75 81 70 66 76 71 70 75 73 72
74 81 79 76 71 81 70 75 77 75 72 73 90 65
83 80 84 84 84 82 82 84 82 81 79 81 76 81
85 85 87 85 96 85 86 85 85 95 84 85 84


每一行应该是15个数字,一共八行,每一行代表不同的含义:

Row 1 is the satisfaction of males flying Delta airlines

Row 2 isthe satisfaction of females flying Delta airlines      

Row 3 is the satisfaction of males flyingSouthwest airlines

Row 4 is the satisfaction offemales flying Southwest airlines

Row 5 is the satisfaction of males flyingAmerican airlines

Row 6 isthe satisfaction of females flying American airlines

Row 7 is the satisfaction of malesflying United airlines

Row 8 isthe satisfaction of females flying United airlines


然后要用loop进行整理把数据变成univariate,理想情况应该是

航空公司名字,性别,满意度


楼主写的code是这样的:

Data airline;

Infile 'C:\Users\Downloads\airline.txt' DLM='' missover;

do carrier="delta airlines","southwest airlines","american airlines","united airlines";

do sex="males","females";

do subj=1 to 15;

input rating @;

If rating=. then delete else output;

output;

end;

end;

end;

run;

proc print data=airline;

run;



但是运行出来全部变成了一个航空公司一个性别。。。



不知道code应该怎么改??

请懂的大神指教一下~~

谢谢~~


最佳答案

关键词:Input loop Data put satisfaction

沙发
teqel 发表于 2015-11-8 04:15:16
  1. do carrier="delta airlines","southwest airlines","american airlines","united airlines";
  2. do sex="males","females";
  3. do subj=1 to 15;
  4. input rating @;
  5. If rating~=. then output;
  6. end;
  7. input rating;
  8. end;
  9. end;
复制代码

藤椅
johnpark1 发表于 2015-11-8 12:07:26 来自手机
In your code, try @@ (you had one @); also I think you have duplicates in output. Do you have missing values?

板凳
johnpark1 发表于 2015-11-8 12:33:25 来自手机
Did you try?

报纸
priis 发表于 2015-11-8 13:45:20
johnpark1 发表于 2015-11-8 12:07
In your code, try @@ (you had one @); also I think you have duplicates in output. Do you have missin ...
thank you for you reply.
I tried @@ but didn't work.
Maybe sth wrong with missing variable

地板
priis 发表于 2015-11-8 13:45:55
teqel 发表于 2015-11-8 09:30
谢谢,现在电脑上没有sas明天早上运行试试看!!

7
priis 发表于 2015-11-10 01:46:33
teqel 发表于 2015-11-8 04:15
Just run the code, perfect!
thanks a lot!

8
junge1018 发表于 2015-11-25 10:52:37
priis 发表于 2015-11-10 01:46
Just run the code, perfect!
thanks a lot!
你知道为什么行的通吗

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-29 18:22