SAS Macro variable to represent what is in an IN statement in Proc SQL -


i have query want run through sas in proc sql getting data 1 of our company databases. @ top of query, ease of use mostly, want able put list of input variables. interested in getting data in dates , states. dates care contiguous make sas macro variable start date , end date , use between statement. that's easy enough. but, states, can't such thing. so, thought like

%let states = ('ct', 'md', 'me', 'nc', 'wv'); 

and later on, want statement

where (state_tp in &states) 

now, not work. and, i've tried several other variations can't seem work. possible?

while code fine is, better solution (that might have less issues anyway) create dataset desired states, , join against (or use exists clause if better needs). easier maintain (as can keep dataset in editable format separate code, in excel) , may faster in cases.

data states; input state_tp $; datalines; ct md me nc wv ;;;; run;  proc sql; create table test select z.*   sashelp.zipcode z  inner join  states s   on z.state_tp=s.state_tp; quit; 

or

proc sql; create table test select * sashelp.zipcode z exists (   select 1 states s    s.state_tp=z.state_tp); quit; 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -