全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
11120 13
2012-05-29
请问怎么将一个已有format的数据集,去掉format。因为带有foramt的数据集转移到其他电脑里面的时候总是需要先运行format,才能操作数据集,很麻烦。
求助求助!!
二维码

扫码加我 拉你入群

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

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

全部回复
2012-5-29 15:10:16
One method invokes the "PROC DATASETS" procedure.
1. Start the SAS software package and load the SAS program. Locate the name of the dataset within the program that uses the desired formats.
2. Modify the dataset characteristics. Type the following code in the SAS editor to remove or drop an existing format:

PROC DATASETS LIB=FormatLocation;
MODIFY YourSASDatasetName;
format _all_;
RUN;

where "FormatLocation" is the location of the SAS format (work, for example) and "YourSASDatasetName" is the name of the SAS dataset. Use the "format _all" option to drop all SAS formats or specify the format name in the place of "_all_".
二维码

扫码加我 拉你入群

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

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

2012-5-29 15:14:13
The other uses "DATA" steps. Both methods can be invoked to drop all formats associated with a particular SAS dataset or be limited to specific formats.

1. Start the SAS software package and load the SAS program. Locate the name of the dataset within the program that uses the desired formats.
2. Type the following code in the SAS editor:

DATA YourNewDatasetName;
SET YourCurrentDataset;
FORMAT _ALL_;
RUN;

where "YourNewDatasetName" is the newly created dataset and "YourCurrentDataset" is the name of the SAS dataset to be modified. Use the "format _all" option to drop all SAS formats or specify the format name in the place of "_all_".

3. Execute the piece of code.
4. Eventually, run a "PROC CONTENTS" to verify the removal of the formats.
二维码

扫码加我 拉你入群

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

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

2012-5-29 15:17:28
davil2000 发表于 2012-5-29 15:10
One method invokes the "PROC DATASETS" procedure.
1. Start the SAS software package and load the S ...
这位老大您好,非常感谢帮忙。除了这点问题之外,还有部分问题;
我需要处理多个数据集,将每个数据集里面的format按照数据集进行分别储存;
例如
数据集      format存储集
a1           a1f
a2           a2f
a3          a3f
本打算使用
proc format cntlout=b1 library=work;
run;
quit;
结果发现这个结果不能区分数据集,是将所有数据集的format集中到一起,所以我打算按照数据集分别处理,在处理完a1之后将所有的format去掉,在处理a2;使用上面的代码,发现数据集a1里面是没有了,但是在work里面还是有format的那个图标,使用proc format cntlout还是会输出a1的内容!!
二维码

扫码加我 拉你入群

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

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

2012-5-29 15:40:26
Easy! For evey data set  ***, you can choose to keep only one obs, and save it as ***f.  In such a way, u can save format for each data set.
In the flllowing application, simply append the *** data set (in which formats  has been deleted ) to the data set   ***f,  and then delete the 1st obs.
Good luck!
二维码

扫码加我 拉你入群

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

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

2012-5-29 16:11:17
davil2000 发表于 2012-5-29 15:40
Easy! For evey data set  ***, you can choose to keep only one obs, and save it as ***f.  In such a w ...
我还是上实例吧,这样比较方便:我有两个数据集,需要分别得到他们的format列表(真实情况是有很多个数据集,所以不能运行完一个之后关闭在运行另外一个);两个数据集分别为:
proc format;
value f1_fmt 1 = '研究药物' 2 = '对照药物';
value f2_fmt 1 = '男' 2 = '女';
run;
data a1;
format group f1_fmt. sex f2_fmt.;
label group = '组别' age = '年龄' sex = '性别';
do subid = 1 to 2;
   group = mod(subid, 2) + 1;
   age = 18 + int(ranuni(0) * 42);
   sex = ceil(ranuni(0) * 2);
   output;
end;
run;

proc format;
value f1_fmt 1 = '北京' 2 = '天津';
value f2_fmt 1 = '小学生' 2 = '中学生' 3='高中生' 4='大学生';
value f3_fmt 1 = '自费' 2 = '保险' 3='社保';
run;
data a2;
format group f1_fmt. edu f2_fmt. pay f3_fmt.;
label group = '城市' age = '年龄' edu = '学历' pay='付费方式';
do subid = 1 to 4;
   group = mod(subid, 2) + 1;
   age = 18 + int(ranuni(0) * 42);
   edu = ceil(ranuni(0) * 4);
   pay=ceil(ranuni(0) * 3);
   output;
end;
run;

我需要分别得到他们的format列表,我使用的方法是:
proc format cntlout=a1f;
run;

需要得到的format列表分别为
a1f
QQ截图20120529160940.png
a2f
QQ截图20120529161023.png
现在因为运行完前面的a1之后,a1的format还存在,如果在a2生成之后运行
proc format cntlout=a2f;
run;
那么a2f里面也会包含或者错误显示a1的format内容,所以想问一下能否在a1的a1f生成之后,将work里面的formats文件夹删除,使其不再影响a2f的内容
附件列表
QQ截图20120529160940.png

原图尺寸 4.72 KB

QQ截图20120529160940.png

二维码

扫码加我 拉你入群

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

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

点击查看更多内容…
相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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