f*****k 发帖数: 110 | 1 I have a variable X whose values and value labels like these:
X's values value labels
------------------------------
unknown concentration
low low concentration
mid middle concentration
high high concentration
I want to use a macro to automatically recode a new variable Y like this:
Y's values value labels
------------------------------
X_ unknown concentration (X to Y)
X_low low concentration (X to Y)
X_mid middle concentration (X to Y)
X_high high concentration (X to Y)
How should I do so? Thanks a lot! | a*****3 发帖数: 601 | | l*********s 发帖数: 5409 | 3 not good for showing off :-)
【在 a*****3 的大作中提到】 : 好奇手写不行么? 非要macro?
| f*****k 发帖数: 110 | 4 Definitely not showoff. I need to do hundreds of variables like this, so I
have to use macro.
【在 l*********s 的大作中提到】 : not good for showing off :-)
| a*****3 发帖数: 601 | 5 还是不明白这种low,mid,high怎么会有上百种情况, anyway 也许可以这么做:
1.你把这几百种情况写出来,
2.倒进dataset里面,用begin,label,hlo,etc做header
3.用proc format读进来,用cntlin= 选项
不过又做1的功夫, 直接在proc format手写也写出来了.
【在 f*****k 的大作中提到】 : Definitely not showoff. I need to do hundreds of variables like this, so I : have to use macro.
| l*********s 发帖数: 5409 | 6 You don't need to do 1 manually. You can output format with proc format into
a dataset and modify it with data step.
【在 a*****3 的大作中提到】 : 还是不明白这种low,mid,high怎么会有上百种情况, anyway 也许可以这么做: : 1.你把这几百种情况写出来, : 2.倒进dataset里面,用begin,label,hlo,etc做header : 3.用proc format读进来,用cntlin= 选项 : 不过又做1的功夫, 直接在proc format手写也写出来了.
| f*****k 发帖数: 110 | 7 I need to do such X -- Y transformation for hundreds of other variables Z1 .
.. Z500, whose values are not always "low, mid or high". Eg., Z1 may have
values as "empty" and "red". More importantly, in another dataset, the
variables and values may change. So, ideally, I hope to have a macro that
can automatically do such transformation for any given variable in any given
dataset.
【在 a*****3 的大作中提到】 : 还是不明白这种low,mid,high怎么会有上百种情况, anyway 也许可以这么做: : 1.你把这几百种情况写出来, : 2.倒进dataset里面,用begin,label,hlo,etc做header : 3.用proc format读进来,用cntlin= 选项 : 不过又做1的功夫, 直接在proc format手写也写出来了.
|
|