SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 741|回复: 2
打印 上一主题 下一主题

菜鸟跪求帮我解释一下这个程序

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2008-10-15 09:03:32 | 只看该作者

菜鸟跪求帮我解释一下这个程序

data birthstones;
       drop Space Stone;
       retain Month Modern Traditional Mystica  Ayurvedic Other1-Other3;
       infile 'raw-data-file' end=LastMonth dlm=',';
       length Month $ 9 Modern Traditional $ 12   Mystical $ 11 Ayurvedic $ 10 Other1-Other3 $ 15;
       input @1 Space $1. @;
       if Space ne ' ' then do;
               if _n_ ne 1 then output;
                      input @1 Month $;
                       Stone=1;
                       Other2='';
                       Other3='';
end;
else do;
      if Stone = 1 then input Modern $;
     else if Stone = 2 then input Traditional;
     else if Stone = 3 then input Mystical;
     else if Stone = 4 then input Ayurvedic;
     else if Stone = 5 then input Other1;
     else if Stone = 6 then input Other2;
     else if Stone = 7 then input Other3;
     Stone+1;
end;
    if LastMonth then output;
run;
proc print data=birthstones;
      title 'Various Birthstones for Each Month';
run;
我想请教一下retain语句以及‘end=’语句以及if Space ne ' ' then do和 if _n_ ne 1 then output在这个程序中分别表示什么意思,以及各有什么用处?非常感谢!!!
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
沙发
 楼主| 发表于 2008-10-15 09:14:35 | 只看该作者

Re: 菜鸟跪求帮我解释一下这个程序

这里是Sample Records;
January
Garnet
Garnet
Emerald
Garnet
Rose Quartz
February
Amethyst
Amethyst
Bloodstone
Amethyst
Onyx
Moonstone
March
Aquamarine
Bloodstone
Jade
Bloodstone
Rock Crystal

这里是最后所得结果
work.birthstones
Various Birthstones for Each Month
Obs Month Modern Traditional Mystical Ayurvedic
1 January Garnet Garnet Emerald Garnet
2 February Amethyst Amethyst Bloodstone Amethyst
3 March Aquamarine Bloodstone Jade Bloodstone
4 April Diamond Diamond Opal Diamond
5 May Emerald Emerald Sapphire Agate
6 June Pearl Alexandrite Moonstone Pearl
7 July Ruby Ruby Ruby Ruby
8 August Peridot Sardonyx Diamond Sapphire
9 September Sapphire Sapphire Agate Moonstone
10 October Opal Tourmaline Jasper Opal
11 November Yellow Topaz Citrine Pearl Topaz
12 December Blue Topaz Zircon Onyx Ruby
Obs Other1 Other2 Other3
1 Rose Quartz
2 Onyx Moonstone
3 Rock Crystal
4 Quartz White Sapphire
5 Chrysoprase Beryl
6 Opal Moonstone
7 Carnelian
8 Jade
9 Lapis Lazuli Diamond Chrsolite
10 Pink Tourmaline Zircon Aquamarine
11 Diamond
12 Turquoise Lapis Lazuli
回复 支持 反对

使用道具 举报

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
板凳
 楼主| 发表于 2008-10-15 22:18:12 | 只看该作者

Re: 菜鸟跪求帮我解释一下这个程序

there's no need of "跪求". you may just download 'SAS on-line tutor for base certification' at the ftp site and read section 'reading various types of raw data' -> 'reading hierarchical files'.
回复 支持 反对

使用道具 举报

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

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2026-2-5 01:31 , Processed in 0.066020 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表