SAS中文论坛

标题: 生成数据集 [打印本页]

作者: shiyiming    时间: 2010-1-28 15:22
标题: 生成数据集
有5个变量,分别为[b:1bikg1zd]name[/b:1bikg1zd],[b:1bikg1zd]type[/b:1bikg1zd] (NP for national park or NM for national monument), [b:1bikg1zd]region[/b:1bikg1zd] (East or West),[b:1bikg1zd]meseums[/b:1bikg1zd](number
of museums),[b:1bikg1zd]camping[/b:1bikg1zd](number of campgrounds),数据如下:

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

不对上数据作任何变动,生成上数据的数据集。
谢谢!!!
作者: shiyiming    时间: 2010-1-28 15:52
标题: Re: 生成数据集
LAOMAI  <!-- s:D --><img src="{SMILIES_PATH}/icon_biggrin.gif" alt=":D" title="Very Happy" /><!-- s:D -->
作者: shiyiming    时间: 2010-1-28 16:20
标题: Re: 生成数据集
CAUTION:仅用于9.2
[code:1w6ntt8q]data raw(drop=position length);
        length Name $20 Type $2 Region $4;
        input;
        call scan(_infile_,-4,position,length,' ');
        name=substrn(_infile_,1,position-2);
        type=scan(_infile_,-4,' ');
        region=scan(_infile_,-3,' ');
        Meseums=input(scan(_infile_,-2,' '),best&#46;);
        Camping=input(scan(_infile_,-1,' '),best&#46;);
datalines;
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 &#46; 2 2
Yellowstone NP West 9 11
Yosemite NP West 2 13
;[/code:1w6ntt8q]
作者: shiyiming    时间: 2010-1-28 16:33
标题: Re: 生成数据集
谢谢!程序有点看不懂。




欢迎光临 SAS中文论坛 (https://mysas.net/forum/) Powered by Discuz! X3.2