由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 一个关于macro的问题,多谢。
相关主题
How to the macro regression with if?sas question
一道ADV 130 题目Help! A data step problem
proc iml help!请教一个SAS Macro问题。谢谢
SAS ADVANCED 一道题求助a sas adv question
一个常见的问题macro variable 的问题
问一些sas的问题how to make this macro work, thanks
SAS Macro 问题请教 。。。SAS Regression Macro 问题请教 (有包子)
急问这个SAS的code该怎么写请教一个macro的问题
相关话题的讨论汇总
话题: label话题: macro话题: var话题: variable话题: do
进入Statistics版参与讨论
1 (共1页)
h**s
发帖数: 6
1
我想把变量 a,b,c 作不同的label,分别是aaa,bbb,ccc。该怎么label呢?实际上我有
很多变量需要label,所以想要用macro。下面是数据的一部分,多谢多谢。
我现在只能想出如何一次作同样的label,比如a,b,c,都成aaa.但这不是我想要的,多
谢。
DATA cars1;
INPUT a b c;
CARDS;
22 2930 4099
17 3350 4749
22 2640 3799
20 3250 4816
15 4080 7827
;
RUN;
h**h
发帖数: 488
2
Don't quite get it. If just lable the variables, you can use proc format to
give names to the desired variables.

【在 h**s 的大作中提到】
: 我想把变量 a,b,c 作不同的label,分别是aaa,bbb,ccc。该怎么label呢?实际上我有
: 很多变量需要label,所以想要用macro。下面是数据的一部分,多谢多谢。
: 我现在只能想出如何一次作同样的label,比如a,b,c,都成aaa.但这不是我想要的,多
: 谢。
: DATA cars1;
: INPUT a b c;
: CARDS;
: 22 2930 4099
: 17 3350 4749
: 22 2640 3799

c********s
发帖数: 483
3
Do you mean label for variable name?
If you do not know how many variables on dataset
You may use 1>. sashelp to get variable name,
2>. Proc sql select into: to get macro list
3>. proc sql select n() to get count macro
4>. Using do loop or array to label variable using your label
rule.
f********m
发帖数: 197
4
Is it possible that you define two arrays, one store variable name, one
store newlabel,say
...
array varname{3} $ ('a' 'b' 'c');
array label_of_var{3} $ ('aaa','bbb','ccc');
...
Then you define the macro as
%macro labels (var_to_label=, label_of_var=);
...
label &var_to_label = &label_of_var;
...
%mend;
do i=1 to 3;
%labels(var_to_label=varname{i}, label_of_var=newlabel{i});
end;
May worth a shot. But I'm not sure if it will work. :)

【在 h**s 的大作中提到】
: 我想把变量 a,b,c 作不同的label,分别是aaa,bbb,ccc。该怎么label呢?实际上我有
: 很多变量需要label,所以想要用macro。下面是数据的一部分,多谢多谢。
: 我现在只能想出如何一次作同样的label,比如a,b,c,都成aaa.但这不是我想要的,多
: 谢。
: DATA cars1;
: INPUT a b c;
: CARDS;
: 22 2930 4099
: 17 3350 4749
: 22 2640 3799

n********6
发帖数: 1511
5
Thank you for your comments. It also reminds me the dictionary table.

【在 c********s 的大作中提到】
: Do you mean label for variable name?
: If you do not know how many variables on dataset
: You may use 1>. sashelp to get variable name,
: 2>. Proc sql select into: to get macro list
: 3>. proc sql select n() to get count macro
: 4>. Using do loop or array to label variable using your label
: rule.
:

1 (共1页)
进入Statistics版参与讨论
相关主题
请教一个macro的问题一个常见的问题
SAS call symput question问一些sas的问题
ask for help (urgent): A SAS questionSAS Macro 问题请教 。。。
请教一道SAS maro的题急问这个SAS的code该怎么写
How to the macro regression with if?sas question
一道ADV 130 题目Help! A data step problem
proc iml help!请教一个SAS Macro问题。谢谢
SAS ADVANCED 一道题求助a sas adv question
相关话题的讨论汇总
话题: label话题: macro话题: var话题: variable话题: do