楼主: dxystata
2225 5

如果通过proc sql 得到grp format前的值 [推广有奖]

版主

大师

34%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
182303 个
通用积分
15205.6089
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
291306 点
帖子
5378
精华
1
在线时间
13479 小时
注册时间
2006-6-21
最后登录
2024-4-28

初级学术勋章 初级热心勋章 中级热心勋章 初级信用勋章

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.;
关键词:proc sql format FORMA form For 如何

本帖被以下文库推荐

沙发
Eternal0601 发表于 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.;

使用道具

藤椅
dxystata 发表于 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;

使用道具

板凳
Eternal0601 发表于 2013-12-18 19:12:56 |只看作者 |坛友微信交流群
dxystata 发表于 2013-12-18 05:31
如果是这样呢?
proc format;
        value $sex  "1"='f'
把sql中相应的fomat=1改为format $1.就好的,匹配下

使用道具

报纸
bobguy 发表于 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;

使用道具

地板
Eternal0601 发表于 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.

使用道具

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

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-28 15:59