楼主: rockfido
4286 20

请教SAS 数据处理问题 [推广有奖]

11
crackman 发表于 2010-3-2 07:41:19
学习了 呵呵
谢谢楼主

12
rockfido 在职认证  发表于 2010-3-2 08:39:46
错了,该谢的是二楼的jingju11!!我就是一只SAS小菜鸟。。。很多问题都不明白。。。哈哈


11# crackman

13
jingju11 发表于 2010-3-2 12:06:30
rockfido 发表于 2010-3-2 07:25
so in that case, all the first 1999 obs are not valid but only the last line is needed? because, I guess for n_, the 2000 obs should be valuing from 1, 2, 3, until 2000?

do u have any idea how could i add those p1_, p2_, p3_ as the last three observations under each variables (instead of being added as 3 new variables....)

thanks a lot!

8# jingju11
According to my experience, before coding you’d better know what you need. Personally, I think, outputing to 3 additional lines is not good. Anyway, you can do like that:



  1. set .. end = Eof;
  2. ....
  3. output;
  4. if Eof then do;
  5.    do i = 1 to 1000;
  6.       test{i} = p1_{i}; output;
  7.       test{i} = p2_{i}; output;
  8.       test{i} = p3_{i}; output;
  9.    end;
  10. end;
复制代码

14
rockfido 在职认证  发表于 2010-3-2 12:15:26
i totally agree with you. actually either way works for my project. since i kept on thinking about adding 3 lines but without any idea, i'm just so curious about how to fulfill it. and ur rite, adding 3 lines actually doesnt make much sense, but just for some little advantage for my project.

thank you so much!

13# jingju11
已有 1 人评分经验 论坛币 收起 理由
bakoll + 3 + 3 精彩帖子

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

15
08liurenxing 发表于 2010-3-2 13:15:22
学习了,我啥时候到这个水平就好了

16
rockfido 在职认证  发表于 2010-3-2 23:34:59
1# rockfido

BTW, I HAVE ANOTHER QUESTION, BY USING: "ARRAY TEST{1000}" IN THE DATA B STEP, WE DONT NEED TO USE: ARRAY TEST{1000} TEST1--TEST1000 FOR LOADING THE ARRAY?

17
jingju11 发表于 2010-3-2 23:40:56
rockfido 发表于 2010-3-2 23:34
1# rockfido

BTW, I HAVE ANOTHER QUESTION, BY USING: "ARRAY TEST{1000}" IN THE DATA B STEP, WE DONT NEED TO USE: ARRAY TEST{1000} TEST1--TEST1000 FOR LOADING THE ARRAY?
Right. That is SAS default. When you did not specify the variable names, SAS will create or look for the variables of array name followed by numbers in order. For example

Array x{2};
ó array x{2} x1 x2;

18
rockfido 在职认证  发表于 2010-3-3 05:01:39
13# jingju11

one more silly question......should it work? i tried (but probably with some problem?), and it seems that the portion will be replacing the last obs instead of appending after the last one....

19
jingju11 发表于 2010-3-3 06:42:19
rockfido 发表于 2010-3-3 05:01
13# jingju11

one more silly question......should it work? i tried (but probably with some problem?), and it seems that the portion will be replacing the last obs instead of appending after the last one....
……
if Eof then do;

do i = 1 to 1000;

test{i} = p1_{i};

end;

output;


do i = 1 to 1000;

test{i} = p2_{i};

end;

output;


do i = 1 to 1000;

test{i} = p3_{i};

end;

output;


end;
run;


NOTE: There were 2000 observations read from the data set WORK.A.
NOTE: The data set WORK.B has 2003 observations and 8000 variables.
NOTE: DATA statement used (Total process time):
      real time           2.57 seconds
      cpu time            0.25 seconds


Sorry I made a mistake.

20
rockfido 在职认证  发表于 2010-3-3 07:35:30
19# jingju11

No, I should THANK YOU.....I guess Im just far away from being good at SAS programming...especially of dealing with the array there...I got the idea u used in ur program but I even cant debug the problem....TOO BAD.....but i will try harder!!

Thank you so much!!

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

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