I am working on a project in wich i have data at a particular geographical level. Due to historical reasons, these areas are indexed as :
01 02 ... 19 2A 2B 21 ... 95
I have a program I want to run on each of these areas, for which the database is indexed sthg_dtheindex (sthg_d01; sthg_d2A...), and merge them with a national database for which I have this index of geographical area (it is dep)
For now what I have done is to create a table with corresponding indexes (1:01 ; 2:02 ; 19 : 19 ; 20 : 21 ; 28 : 29 ; 29 : 2A ; 30 : 2B ; 31 : 30...) and I then try to merge by searching each file in this list. It works for the numerical indexes, but infortunately it does not work for the two indexes in character, I get
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).
Which is in english:
ERROR 388-185: Expecting an arithmetic operator.
ERROR 202-322: The option or parameter is not recognized and will be ignored.
Here is my code
%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;
It is here that I have my problem, in the if 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;
Since dep
is defined as $2 character variable, it needs to be compared to string constant like this:
if dep="&&&d&i";