我有一個我想要循環的列表(頻率)。例如列表:避免將標點符號作爲列表中的分隔符
%let Freq_list = min5 min2 sec60.31 sec30;
作爲默認SAS對待punctation在 「sec60.31」 作爲分隔符。如何避免使用標點符號(「。」)作爲列表中的分隔符?
我想遍歷這個頻率列表,然後希望「sec60.31」成爲一個這樣的成員從列表中提取。
更多代碼(程序的一部分):
%let n_f = %sysfunc(countw(&freqlist));
%do I_f=1 %to &n_f;
%let freq = %scan(&freqlist,&I_f);
%let freqtext = %scan(&freqtextlist,&I_f);
proc timeseries data=[datafile] out= [datafile]_&freqtext.;
where weekday between 2 and 6;
id datetime interval=&freq accumulate=last setmissing=missing align=beg start = '01jan1999.00:05'dt end = '01dec2014.00:00'dt;
var price;
run;
%end;
其結果是,它運行PROC時間序列與「間隔= sec60」,然後產生以下錯誤,當涉及到的「31」 -part :
NOTE: Line generated by the macro variable "FREQ".
1 31
--
22
200
ERROR 22-322: Syntax error, expecting one of the following: a name, a format name.
ERROR 200-322: The symbol is not recognized and will be ignored.
計數器& n_f表明COUNT星期功能治療 「」作爲分隔符,所以我想我都需要COUNTW函數和SCAN函數來識別分隔符。
正如你可能已經注意到我有另外一個列表中的文件名等使用
我的問題%let Freq_textlist = min5 min2 min1 sec30;
一種解決方案可能是從該名單中(這是相等的長度)得到計數器& n_f和我freq_list更改爲:
%let Freq_list = [email protected]@[email protected];
,並使用掃描%與定界符放慢參數,如:
%let freq = %scan(&freqlist,&I_f,@);
此工作無需處理COUNTW如何識別「。」因爲不是分隔符。
你能張貼代碼和結果? – NEOmen
你嘗試過使用%str嗎? %freq_list =%str(min5 min2 sec60.31 sec30); 也你如何循環頻率?用%掃描你可以設置一個分隔符,這是請求的結果? – stat