由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - 请教 如何用macro variabe 传递数值?
相关主题
请教这种freq 该用什么code算(sas)?Thanks!SAS ADV passed!!!
SAS help: 在 Macro 里循环调用 windows-display 的问题[合集] 一个sas问题
请教一个call symput的问题靠,这个哪错了?
SAS Macro Function请帮忙看3道SAS题。
[SAS]怎么快捷地删除Macro 里创建的临时dataset和macro variab[合集] sas advance question
SAS help : The scope of macro variableswhy this error in %if statement
求教如何根据每一行创建一个满足条件的宏变量?非常有挑战性的问题!菜鸟请教关于赋给macro variables变量值
请教sas问题[合集] 一道SAS Advanced 题目--关于call symput
相关话题的讨论汇总
话题: end话题: weight话题: start话题: weight1话题: variabe
进入Statistics版参与讨论
1 (共1页)
v*******g
发帖数: 334
1
start end weight1 weight2 weight3 weight4 weight_start weight_end
1 2 1.21 1.22 1.23 2.31 1.21 1.22
2 3 1.22 1.24 1.25 2.35 1.24 1.25
1 3 1.24 1.28 1.28 2.38 1.24 1.28
2 4 1.26 1.21 1.25 2.39 1.21 2.39
这是数据
start end weight1-4 是已有的变量, 现根据这6个变量给 weight_start 和
weight_end
赋值。我想的是下面的方法,可是太罗嗦了。怎么用 macro variabe 简化呢?
SAS code
A*******s
发帖数: 3942
2
这个用不着macro variable,直接用数组下标就行
data aaa;
array weight{4};
input start end weight1-weight4;
weight_start=weight(start);
weight_end=weight(end);
cards;
1 2 1.21 1.22 1.23 2.31
2 3 1.22 1.24 1.25 2.35
1 3 1.24 1.28 1.28 2.38
2 4 1.26 1.21 1.25 2.39
;
run;

end

【在 v*******g 的大作中提到】
: start end weight1 weight2 weight3 weight4 weight_start weight_end
: 1 2 1.21 1.22 1.23 2.31 1.21 1.22
: 2 3 1.22 1.24 1.25 2.35 1.24 1.25
: 1 3 1.24 1.28 1.28 2.38 1.24 1.28
: 2 4 1.26 1.21 1.25 2.39 1.21 2.39
: 这是数据
: start end weight1-4 是已有的变量, 现根据这6个变量给 weight_start 和
: weight_end
: 赋值。我想的是下面的方法,可是太罗嗦了。怎么用 macro variabe 简化呢?
: SAS code

A*******s
发帖数: 3942
3
还有你这个if语句写得也不是很好,互斥的条件应该用if else的,或者用select when

【在 A*******s 的大作中提到】
: 这个用不着macro variable,直接用数组下标就行
: data aaa;
: array weight{4};
: input start end weight1-weight4;
: weight_start=weight(start);
: weight_end=weight(end);
: cards;
: 1 2 1.21 1.22 1.23 2.31
: 2 3 1.22 1.24 1.25 2.35
: 1 3 1.24 1.28 1.28 2.38

v*******g
发帖数: 334
4
thanks,Actuaries ,it does work.
v*******g
发帖数: 334
5
but when i tested the codes on another dataset with missing value in it , it
did not work

【在 A*******s 的大作中提到】
: 这个用不着macro variable,直接用数组下标就行
: data aaa;
: array weight{4};
: input start end weight1-weight4;
: weight_start=weight(start);
: weight_end=weight(end);
: cards;
: 1 2 1.21 1.22 1.23 2.31
: 2 3 1.22 1.24 1.25 2.35
: 1 3 1.24 1.28 1.28 2.38

v*******g
发帖数: 334
6
But this macro variables do not work either
data aaa;
set aaa;
age1=compress("weigh"||start);
age2=compress("weigh"||end);
call symput('age_start',age1);
call symput('age_end',age2);
age_start= &age_start;
age_end= &age_end;
run;
A*******s
发帖数: 3942
7
which variable has missing values? weight1-weight4 should be OK with missing
values but start and end are not.

it

【在 v*******g 的大作中提到】
: but when i tested the codes on another dataset with missing value in it , it
: did not work

P****D
发帖数: 11146
8
有很多老年人都不知道select-when,具体我也不知道这个语法是哪年添加进SAS的。贱
妾被请教“你写的这个这是什么意思”两次了。

when

【在 A*******s 的大作中提到】
: 还有你这个if语句写得也不是很好,互斥的条件应该用if else的,或者用select when
v*******g
发帖数: 334
9
Yes, there are missing in start and end/ thanks,

missing

【在 A*******s 的大作中提到】
: which variable has missing values? weight1-weight4 should be OK with missing
: values but start and end are not.
:
: it

v*******g
发帖数: 334
10
isn't PharmD better than statistics ?

【在 P****D 的大作中提到】
: 有很多老年人都不知道select-when,具体我也不知道这个语法是哪年添加进SAS的。贱
: 妾被请教“你写的这个这是什么意思”两次了。
:
: when

A*******s
发帖数: 3942
11
so how do you deal with this? Just assign missing values to weight_start and
weight_end? If so, you can use if-else statements.

【在 v*******g 的大作中提到】
: Yes, there are missing in start and end/ thanks,
:
: missing

v*******g
发帖数: 334
12
Yes, as you said , I used if-else to solve the missing problem
1 (共1页)
进入Statistics版参与讨论
相关主题
[合集] 一道SAS Advanced 题目--关于call symput[SAS]怎么快捷地删除Macro 里创建的临时dataset和macro variab
问个SAS题目,SAS help : The scope of macro variables
how to create page x of y in SAS求教如何根据每一行创建一个满足条件的宏变量?非常有挑战性的问题!
killtest Q78 79 80请教sas问题
请教这种freq 该用什么code算(sas)?Thanks!SAS ADV passed!!!
SAS help: 在 Macro 里循环调用 windows-display 的问题[合集] 一个sas问题
请教一个call symput的问题靠,这个哪错了?
SAS Macro Function请帮忙看3道SAS题。
相关话题的讨论汇总
话题: end话题: weight话题: start话题: weight1话题: variabe