A*******s 发帖数: 3942 | 1 google了一下,没找到答案。
问题是这样的,假如我有自定义的format如下
proc format;
value aaa 1=2
2=4
;
run;
那么我想根据format的值,而不是原来的值,来计算一个data set的basic statistics
, 怎么办?sas的proc有没有统一的option是干这个的?
我用proc里的format statement,计算的还是原来的值。
比如说对于数据(1,2)来说,其mean应该是1.5,
但是我想用format后的数据(2,4)来算,mean该是3.
我把问题说明白没?谢谢大家。 |
s******y 发帖数: 352 | 2 if you understand the definition of FORMAT, you will know it is impossible.
but if you create a new variable with input/Put transformations, the
statistic based upon the new var is what you need. |
A*******s 发帖数: 3942 | 3 damn, what if I have thousands of variables? I hate writing macros...
I was thinking using proc print with ods output to get the data after
normalization/transformation. It turns out that proc print doesn't support
ods...
so what is the FASTEST way to do data normalization/transformation?
impossible.
【在 s******y 的大作中提到】 : if you understand the definition of FORMAT, you will know it is impossible. : but if you create a new variable with input/Put transformations, the : statistic based upon the new var is what you need.
|
s******y 发帖数: 352 | 4 not entirely understand what you are trying to accomplish. but you don't
have to resort the macro, especially as you hate it so much.
alternatively, you can dynamically write statement to a temp file, then
later included with %inc. it is all data-driven.
something like this you could give it a try.
filename temp temp;
data _null_;
set yourvar; *<<-----this is a dataset contains all the variables (name &
format) need
transformation. you can get it from sashelp.vcolumns or
diction |
l***a 发帖数: 12410 | 5 use put function
statistics
【在 A*******s 的大作中提到】 : google了一下,没找到答案。 : 问题是这样的,假如我有自定义的format如下 : proc format; : value aaa 1=2 : 2=4 : ; : run; : 那么我想根据format的值,而不是原来的值,来计算一个data set的basic statistics : , 怎么办?sas的proc有没有统一的option是干这个的? : 我用proc里的format statement,计算的还是原来的值。
|
l*********s 发帖数: 5409 | 6 create a new variable using put and input function
【在 A*******s 的大作中提到】 : damn, what if I have thousands of variables? I hate writing macros... : I was thinking using proc print with ods output to get the data after : normalization/transformation. It turns out that proc print doesn't support : ods... : so what is the FASTEST way to do data normalization/transformation? : : impossible.
|
A*******s 发帖数: 3942 | 7 Thanks guys. Finally I use input and put functions with arrays in data step
to transform data.
The only way I found to directly use "formatted value" is when "formatted
variable" is treated as categorical. E.g, proc freq with format statement. I
have yet found a way to deal with continuous "formatted variable". If
someone has a clue, plz share your experience. |