楼主: zhiyong75
10449 8

[求助]SAS数据集变量属性如何更改 [推广有奖]

  • 0关注
  • 2粉丝

已卖:785份资源

硕士生

97%

还不是VIP/贵宾

-

威望
0
论坛币
2023 个
通用积分
0.1800
学术水平
0 点
热心指数
0 点
信用等级
0 点
经验
184 点
帖子
77
精华
0
在线时间
278 小时
注册时间
2006-9-5
最后登录
2017-8-20

楼主
zhiyong75 发表于 2006-9-19 16:08:00 |AI写论文

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
比如把某一数值型变量更改为字符型分类变量,insight可以实现,但是能否对原数据集也可以实现变换呢?
二维码

扫码加我 拉你入群

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

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

关键词:sas数据集 数据集变量 数据集 Insight 分类变量 变量 SAS 数据集 属性

回帖推荐

zzheng722 发表于7楼  查看完整内容

To convert a numeric value to a character value: use 'put' function with a format. To convert a character value to a numeric value use 'input' fuction with informat. But be very careful with the values with decimals, the following code tells you using different formats and informat s can give you really different results. Using z7. format can help you to insert leading zeros ( '0002007') . To c ...

本帖被以下文库推荐

沙发
coolsky2004 发表于 2006-9-27 01:00:00

使用put(var,var_type);

藤椅
zhiyong75 发表于 2006-9-28 10:23:00

coolsky2004前辈:是不是用如y=put(x,x_char)语句?

如:

data a;
input x;
cards;
1
;
run;
data b;
set a;
y=put(x,x_char);run;

但是运行结果出错,请指教!

板凳
zzyychine 发表于 2006-9-29 03:33:00

到帮助里去找一下吧。

报纸
zhiyong75 发表于 2006-9-29 09:25:00
为什么不直接告诉我答案呢?各位大侠?帮助里面难找啊。

地板
tangjifa 发表于 2006-12-15 20:50:00

使用FSE 数据集

就可以实现

也可以用VIEWSTABLE 建立一个与原数据集一样的数据表

然后在DATA项下点击属性

就可以更改

然后通过数据步换成原来的数据集名就行了。

7
zzheng722 发表于 2007-2-15 06:56:00

convert a numeric value to a character value: use put function with a format

To convert a numeric value to a character value: use 'put' function with a format.

To convert a character value to a numeric value use 'input' fuction with informat.

But be very careful with the values with decimals, the following code tells you using different formats and informat s can give you really different results.

Using z7. format can help you to insert leading zeros ( '0002007') . To convert correct character variable you should use enough width of your infomat, at least 7 for this data, and then tell sas the last digit is a decimal.

data a;

input year yeartxt $;

cards;

2007 02007.2

;

run;

data b;

set a;

year1=put(year, f4.);

year2=put(year, z7.);

yeartxt1=input(yeartxt, f4.);

yeartxt2=input(yeartxt, f5.);

yeartxt3=input(yeartxt, f6.);

yeartxt4=input(yeartxt, f7.);

yeartxt5=input (yeartxt, f2.1);

yeartxt6=input (yeartxt, f3.1);

yeartxt7=input (yeartxt, f4.1);

yeartxt8=input (yeartxt, f5.1);

yeartxt9=input (yeartxt, f6.1);

yeartxt10=input (yeartxt, f7.1);

run;

proc print data=b; run;

Answer: year1 and year2 are both correct. Only yeartxt4 and yeartxt10 are correct!

[此贴子已经被作者于2007-2-15 6:57:45编辑过]

已有 1 人评分经验 论坛币 收起 理由
bakoll + 2 + 10 热心帮助其他会员

总评分: 经验 + 2  论坛币 + 10   查看全部评分

8
agri521 发表于 2007-7-14 14:49:00

9
tianhuo2 发表于 2007-7-19 00:06:00
proc datasets;

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

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