2014-09-29 65 views
0

我正在一個項目中工作,我有特定地理位置的數據。由於歷史的原因,這些地區建立索引:SAS宏程序:統計由數字和字符索引的數據庫

... 2A 2B ...

我有一個程序我想在數據庫索引的每個區域運行sthg_d theindex(sthg_d01; sthg_d2A ...),並將它們與我擁有該地理區域索引的國家數據庫合併(它是dep

現在我已經做了什麼是創建一個表與相應的索引 (1:01; 2:02; 19:19; 20:21; 28:29; 29:2A; 30:2B; 31:30 ...) 然後我嘗試通過搜索此列表中的每個文件進行合併。它適用於數字指標,但infortunately它不會在性格這兩個指標的工作,我得到

ERROR 388-185: Opérateur arithmétique requis. 
ERROR 202-322: L'option ou le paramètre n'est pas reconnu(e) et sera ignoré(e). 

這是英文:

ERROR 388-185: Expecting an arithmetic operator. 
ERROR 202-322: The option or parameter is not recognized and will be ignored. 

這裏是我的代碼

%macro appar(); 

data _null_; 
set dep.dep2; /*the table with (1:01 ; 2:02 ; 19 : 19 ; 20 : 21 ; 28 : 29 ; 29 : 2A ; 30 : 2B ; 31 : 30...) */ 
call symput('d'!!left(_n_),dep2); /* variable with 01;02;... is called dep2 */ 
run; 

%do i=1 %to 96 ; /* 2 pour tester sinon 96 sur la métropole */ 

/* I try to create my subtable i of the national one */ 
data f(keep = dep dirindik); 
    set FoyerN.foyer; 
    length dep $2; 
    dep=substr(dirindik,1,2); 
    if dep=&&&d&i; 
run; 

在這裏,我有我的問題,在如果dep = & & & d & i

/* The core of my problem : the merge */ 
data p; 
    merge f(in=x) PotePrec.pote&anprec._d&&d&i (in=y); 
    by dirindik; 
    if x and y; 
run; 


%end; /* du %do */ 
%mend appar; 

回答

2

由於dep被定義爲2 $字符變量,需要將其相比字符串常量這樣的:

if dep="&&&d&i"; 
+0

不是應該 「&& d&I」?有三個&符號,我想SAS會嘗試解決第一個解析過程中的問題。 – Quentin 2016-08-10 01:11:30