全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
2398 5
2013-12-15
悬赏 50 个论坛币 已解决
sample.rar
大小:(820 Bytes)

 马上下载

本附件包括:

  • sample.sas7bdat



不对数据集进行修改,如果通过proc sql 得到grp format前的值? sql中是否有选项?
proc sql noprint;
   select distinct grp into:colvalues separated by ' '
   from sample;
quit;

最佳答案

Eternal0601 查看完整内容

/*for your reference*/ proc format; value sex 1='f' 2='m'; run; data a; format grp sex.; do grp=1 to 2; output; end; run; proc sql noprint; select distinct ogrp into:colvalues separated by ' ' from(select distinct grp as ogrp format=1. from a); quit; %put &colvalues.;
二维码

扫码加我 拉你入群

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

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

全部回复
2013-12-15 06:17:09
/*for your reference*/
proc format;
        value sex  1='f'
                   2='m';
run;

data a;
        format grp sex.;
        do grp=1 to 2;
                output;
        end;
run;

proc sql noprint;
   select distinct ogrp into:colvalues separated by ' '
   from(select distinct grp as ogrp format=1. from a);
quit;

%put &colvalues.;
二维码

扫码加我 拉你入群

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

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

2013-12-18 05:31:28
Eternal0601 发表于 2013-12-15 06:17
/*for your reference*/
proc format;
        value sex  1='f'
如果是这样呢?
proc format;
        value $sex  "1"='f'
                       "2"='m';
run;
二维码

扫码加我 拉你入群

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

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

2013-12-18 19:12:56
dxystata 发表于 2013-12-18 05:31
如果是这样呢?
proc format;
        value $sex  "1"='f'
把sql中相应的fomat=1改为format $1.就好的,匹配下
二维码

扫码加我 拉你入群

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

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

2013-12-20 11:04:34
Eternal0601 发表于 2013-12-15 06:17
/*for your reference*/
proc format;
        value sex  1='f'
This is a wrong way to get complete list values from a format.

data a;
        format grp sex.;
        do grp=1 to 2;
                output;
        end;
run;

The right way is to use proc format with the cntlout option. See example below.

proc format;
        value sex  1='f'
                   2='m';
run;

proc format cntlout=sex;
run;

proc print data=sex;
run;
二维码

扫码加我 拉你入群

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

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

2013-12-20 18:39:17
bobguy 发表于 2013-12-20 11:04
This is a wrong way to get complete list values from a format.

data a;
I get your point, and your method is to get complete list values from a format. And my method is just get the original value list for the variable in the dataset using the format. Thanks.
二维码

扫码加我 拉你入群

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

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

相关推荐
栏目导航
热门文章
推荐文章

说点什么

分享

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