由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Statistics版 - A quick question about masking in macro
相关主题
【包子】求问个简单sas macro问题急问一个SAS 的常见问题
SAS macro的一个小问题SAS code help needed: multiple do loops do not return what is expected
请教sas code问题Help on a SAS question
overall mean in sas for several variablesStupid SAS programming style is driving me crazy....
SAS问题请教怎么去掉一个CHARACTER VAR中的delimiters
SAS问题再请教用尽心思做好了一个macro
请问怎么样用SAS生成这样一个变量?Need advice on SAS macro debugging
如何用SAS 生成一个组合变量?SAS help : get macro variables as an string but not character variable.
相关话题的讨论汇总
话题: macro话题: qscan话题: m1话题: syspbuff话题: str
进入Statistics版参与讨论
1 (共1页)
s*******f
发帖数: 148
1
i'm trying to scan &syspbuff in order to assign the value to a macro
variable call &cc.
Usually i do it like this:
%macro m1 / parmbuff;
...
%let cc=%scan(&syspbuff,2);
...
%mend m1;
%m1(a,b,c,d,e)
Here &cc will be resolved to b.
But what if i would like to scan some strings with single quotes and commas?
such as:
%m1(%str('a','b','c')*%str('d','e'))
Here * is the delimiter (and i dunno if i treat it right with %str). I wanna
get the 'd','e' part as a whole from the scanning above.
I
l*********s
发帖数: 5409
2
why not pass the whole param list as a whole and qscan it in your macro?
s*******f
发帖数: 148
3
Thanks for the reply! There's some strange problem when i use %qscan here:(
It does work great if i assign the string to a macro var with %let statement:
log:
3688 %let a=%str('a','b'*'c','d');
3689 %put temp1=%qscan(&a,1,*);
temp1='a','b'
3690 %put temp2=%qscan(&a,2,*);
temp2='c','d'
which is exactly what i want. However, for some reason, the scanned value
will include the single parenthesis in my macro program...
code:
%macro m1 / parmbuff;
...
%let cc=%qscan(&syspbuff,&i,*);
%p

【在 l*********s 的大作中提到】
: why not pass the whole param list as a whole and qscan it in your macro?
l***a
发帖数: 12410
4
not familiar with %qscan. do you want to try this?
%let cc=%qscan(&syspbuff,&i+1,*());

statement:

【在 s*******f 的大作中提到】
: Thanks for the reply! There's some strange problem when i use %qscan here:(
: It does work great if i assign the string to a macro var with %let statement:
: log:
: 3688 %let a=%str('a','b'*'c','d');
: 3689 %put temp1=%qscan(&a,1,*);
: temp1='a','b'
: 3690 %put temp2=%qscan(&a,2,*);
: temp2='c','d'
: which is exactly what i want. However, for some reason, the scanned value
: will include the single parenthesis in my macro program...

s*******f
发帖数: 148
5
yeah it works!
Thanks a lot!!!!:D

【在 l***a 的大作中提到】
: not familiar with %qscan. do you want to try this?
: %let cc=%qscan(&syspbuff,&i+1,*());
:
: statement:

1 (共1页)
进入Statistics版参与讨论
相关主题
SAS help : get macro variables as an string but not character variable.SAS问题请教
SAS Macro question about %scan(&covariates,&h)SAS问题再请教
batch?请问怎么样用SAS生成这样一个变量?
[合集] 一个sas问题如何用SAS 生成一个组合变量?
【包子】求问个简单sas macro问题急问一个SAS 的常见问题
SAS macro的一个小问题SAS code help needed: multiple do loops do not return what is expected
请教sas code问题Help on a SAS question
overall mean in sas for several variablesStupid SAS programming style is driving me crazy....
相关话题的讨论汇总
话题: macro话题: qscan话题: m1话题: syspbuff话题: str