楼主: 小鳄鱼a
3716 5

如何在data步中生成字符变量的时候规定它的长度 [推广有奖]

  • 6关注
  • 10粉丝

已卖:280份资源

学科带头人

3%

还不是VIP/贵宾

-

威望
0
论坛币
125 个
通用积分
0.0040
学术水平
40 点
热心指数
45 点
信用等级
43 点
经验
32801 点
帖子
1185
精华
0
在线时间
1539 小时
注册时间
2009-7-16
最后登录
2018-10-5

楼主
小鳄鱼a 发表于 2014-9-7 20:51:55 |AI写论文
5论坛币
rt,显谢谢

最佳答案

teihohou 查看完整内容

proc format; value typefmt 1='$groupx' 2='$groupy' 3='$groupz'; value $groupx 'positive'='agree' 'negative'='disagree' 'neutral'='notsure '; value $groupy 'positive'='accept' 'negative'='reject' 'neutral'='possible'; value $groupz 'positive'='pass ' 'n ...
关键词:data步 字符变量 Data 如何

沙发
teihohou 发表于 2014-9-7 20:51:56
proc format;
   value typefmt 1='$groupx'
                 2='$groupy'
                 3='$groupz';
   value $groupx 'positive'='agree'
                 'negative'='disagree'
                 'neutral'='notsure ';
   value $groupy 'positive'='accept'
                 'negative'='reject'
                 'neutral'='possible';

   value $groupz 'positive'='pass    '
                 'negative'='fail'
                 'neutral'='retest';
run;

data answers;
   length word $ 8;
   input type response $;
   respfmt = put(type, typefmt.);
   word = putc(response, respfmt);
   datalines;
1 positive
1 negative
1 neutral
2 positive
2 negative
2 neutral
3 positive
3 negative
3 neutral
;

藤椅
小鳄鱼a 发表于 2014-9-7 21:49:24
原本有一个数值型的变量,我copy成字符型的,想规定它的长度

板凳
teihohou 发表于 2014-9-8 03:44:52
put(source,format)

报纸
小鳄鱼a 发表于 2014-9-8 09:12:28
teihohou 发表于 2014-9-8 03:44
put(source,format)
format具体填写什么,比如我生成的字符型变量长度是14

地板
teihohou 发表于 2014-9-8 09:59:05
In this example, the first statement converts the values of CC, a numeric variable, into the four-character hexadecimal format, and the second writes the same value that the PUT function returns.
cchex=put(cc,hex4.);
put cc hex4.;

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

本版微信群
加好友,备注cda
拉您进交流群
GMT+8, 2025-12-9 11:18