s*******f 发帖数: 148 | 1 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 |
|
P*****i 发帖数: 63 | 2 今天又想了下,结果取决于函数执行的时序。
一步步细分来看:
%let b=%nrstr(&a);
对于%upcase(&b)的执行时序:
1. 因为&b含有macro trigger,所以先解析到&a
2. 这里谁先谁后很重要,在input stack里接下来一步如果是%upcase接管,
那么%upcase执行后结果变成了&A
3. 下一步,因为upcase已经执行过了,针对&A, word scanner不会再重复执行一遍转换大写的操作,结果只由macro trigger再行解析到begin, 这时候解析&a和&A没区别,都指向begin.
这样解释的关键是在时序上要按照先解析第一步, 然后马上执行upcase操作,之后再解析upcase执行完之后的结果三步来才说的通.
换成QUPCASE执行.
在第二步里同样是换成了&A, 但是因为mask掉了&,结果停留在&A不再做进一步解析.
同样道理来看:
%let a=one;
%let b=two;
%let c=%nrstr(&a &b);
310 The %INDEX Function Chapter 9
%put C: &c
%... 阅读全帖 |
|
l***a 发帖数: 12410 | 3 not familiar with %qscan. do you want to try this?
%let cc=%qscan(&syspbuff,&i+1,*());
statement: |
|
p********a 发帖数: 5352 | 4 ☆─────────────────────────────────────☆
summer06 (littledog) 于 (Thu Oct 4 18:12:43 2007) 提到:
first I generate a macro variable with different values as below
%let width=1 2 3 5 6 4 6;
If I use %scan or %qscan, it would not be able to solve the equation since
it is a character. How can I transfer it to number? I try input, but it does
not work.
like
y=x+%scan(&width,1,''); could not be solved.
thanks
☆─────────────────────────────────────☆
chrd (对酒当歌) 于 (Thu Oct 4 18:50:03 2007) 提到: |
|
R******d 发帖数: 1436 | 5 不知道我理解对了不
data test;
input var1 $ var2 var3;
datalines;
a . 1.1
a 5 .
a 6 .
b 5 0
b 5 0
b 7 .
;
run;
proc sql noprint;select distinct var1 into:vars separated by ' ' from test;quit;
proc sql noprint;select count(distinct var1) into:nvar from test; quit;
%macro test;
%do i=1 %to &nvar;
proc sql noprint;
create table tmp as
select *,max(var3>0) as index,max(var3) as max from test where var1="%qscan(&vars,&i,' ')";
quit;
proc append base |
|
l*********s 发帖数: 5409 | 6 why not pass the whole param list as a whole and qscan it in your macro? |
|
D******n 发帖数: 2836 | 7 create a .vim directory under you home directory(there is a dot before
vim)
and then create a syntax directory under it
and then create a sas.vim file under the syntax directory
==============sas.vim======================
if version < 600
syntax clear
elseif exists("b:current_syntax")
finish
endif
syn case ignore
syn region sasString start=+"+ skip=+\\|\"+ end=+"+
syn region sasString start=+'+ skip=+\\|\"+ end=+'+
" Want region from 'cards;' to ';' to be captured (Bob Heckel)
sy... 阅读全帖 |
|