楼主: dxystata
2446 5

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

版主

已卖:302份资源

大师

37%

还不是VIP/贵宾

-

TA的文库  其他...

Software

中英文Ebook

R学习

威望
2
论坛币
183395 个
通用积分
15333.1475
学术水平
208 点
热心指数
271 点
信用等级
174 点
经验
298627 点
帖子
5586
精华
1
在线时间
13632 小时
注册时间
2006-6-21
最后登录
2025-12-22

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

楼主
dxystata 发表于 2013-12-15 06:17:08 |AI写论文
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
拉您进交流群
GMT+8, 2026-1-11 21:20