SAS: create list of strings in quotation marks as macro variable for input filtration -


i'd use following syntax

data new;    set old (where=(mystring in ('string1','string2',...,'string500'))); run; 

in order filter large input data set. 500 strings @ first contained numeric values in variable "bbb" in dataset "aux". far have created macro variable contains required list of 500 strings following way:

proc sql noprint;    select bbb :stringlist1 separated "',' "    work.aux;  quit; data _null_; call symputx('stringlist2',compress("'&stringlist1'")); run;   data new;    set old (where=(mystring in (&stringlist2))); run; 

... seems work. there warning telling me that

the quoted string being processed has become more 262 characters long. might have unbalanced quotation marks.

results still seem plausible. should worried 1 day results might become wrong?

more importantly: try find way avoid using compress function setting

separated "',' " 

option in way not contain blanks in first place. unfortunately following seems not work:

separated "','" 

it doesn't give me eror message when looking @ macro variable there multipage-mess of red line numbers (the color denotes error messages), empty rows, minus signs, ... . following screenshot shows part of log after running code:

proc sql noprint;    select vnr :stringvar1 separated "','"    work.var_nr_import; quit; %put &stringvar1.; 

enter image description here

have tried make use of str()-function no success far.

i cannot replicate error messages in sas 9.3

if variable numeric don't need quotes in macro variable.

if character try using quote() function.

 proc sql noprint;  select quote(bbb) :stringlist1 separated " "  work.aux;   quit; 

Comments

Popular posts from this blog

java - UnknownEntityTypeException: Unable to locate persister (Hibernate 5.0) -

python - ValueError: empty vocabulary; perhaps the documents only contain stop words -

ubuntu - collect2: fatal error: ld terminated with signal 9 [Killed] -