全部版块 我的主页
论坛 数据科学与人工智能 数据分析与数据科学 SAS专版
1883 2
2018-06-18
如图为谷老师SAS编程演绎关于变量类型转换的语法(图1)以及相关程序(图2和图3)。不懂的是在语法中,input文本转换为数字类型的时候,格式为输入格式,put数字转换为文本时,格式为输出格式,但图2的put所用的格式best.(不为文本的输出格式)和图三的input所用的best.(不为数字的输入格式),望论坛大神指点迷津,小弟不胜感激。
附件列表
微信图片_20180618222729.jpg

原图尺寸 2.85 MB

微信图片_20180618222729.jpg

微信图片_20180618222738.jpg

原图尺寸 3.08 MB

微信图片_20180618222738.jpg

微信图片_20180618222748.jpg

原图尺寸 3.53 MB

微信图片_20180618222748.jpg

二维码

扫码加我 拉你入群

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

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

全部回复
2018-6-19 16:41:43
http://support.sas.com/kb/24/590.html
new_variable=input(original_variable,informat)中的informat是指new_variable的输入格式(数值型格式);
new_variable=put(original_variable,format)中的format是指original_variable的输出格式(数值型格式).

***input();
Convert character to numeric

To convert character values to numeric values, use the INPUT function.

new_variable = input(original_variable, informat.);

The informat tells SAS how to interpret the data in the original character variable.

For example, if you have a simple string of digits like 12345678, you can use the basic numeric informat w.d:

data new;
   char_var = '12345678';
   numeric_var = input(char_var, 8.);
run;

***put();
To convert numeric values to character, use the PUT function:

new_variable = put(original_variable, format.);

The format tells SAS what format to apply to the value in the original variable. The format must be of the same type as the original variable. For example, if you are using the PUT function to convert a numeric value to character, the format must be a numeric format.
二维码

扫码加我 拉你入群

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

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

2018-6-19 22:05:08
priss111 发表于 2018-6-19 16:41
http://support.sas.com/kb/24/590.html
new_variable=input(original_variable,informat)中的informat是指 ...
大哥,太谢谢您了!!!谢谢,谢谢,谢谢
二维码

扫码加我 拉你入群

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

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

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

说点什么

分享

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