powermax
数据集a中的变量jobcat为数值型变量,怎么写程序把它永久性变成字符型变量呢
cran
re set data and use format
powermax
but it just change the format of the variable, it doesn't change the type,
i use the input function newjobcat=input(jobcat,$1.), it doesn't work too.
[quote]引用第1楼cran于2007-04-04 07:25发表的“”:
re set data and use format[/quote]
cran
well,you need to set up the format when using PROC PRINT
gztt
可以通过创建新的变量来进行转变变量类型。
数值型转变成字符型的程序如下:
data a;
input x1 @@;
var_chr=trim(x1);
cards;
25 ````
;
run;
这样通过trim语句就可以将数值型转成字符型的了, 程序中的新变量var_chr就是字符型的了;
另外,字符型也可以通过SAS中的运算法则转成数值型的。因为,在SAS中,没有提供直接转换的指令。程序如下:
data a;
input x2 $ @@;
var_num=x2+0;
cards;
125 ````
;
run;
这样,新变量var_num就自动根据运算法则转成数值型的了。
sadboy01
data c;
input x@@;
cards;
1 2 3 4
;
run;
data d(drop=x);
set c;
y=put(x,2.);
run;
这样也可以吧 y就变成字符型的了 或者导出数据为xls格式 再改应该也行 呵呵 笨法