database - SAS- keep only if in list -


i have macro user can choose file run macro on. know if there way keep 1 variable each dataset chosen , if appears in list of variable names.

so example user enter %let tablen=revinfo; revinfo.sas contains variable revenue not income profit or sales. want 1 variable revenue.

i tried multiple keep statements, errors if tries keep variable not there.

data want; set have.&tablen;     keep     income;     keep     revenue;     keep     profit;     keep     sales; run; 

thanks much, kk

the simplest way of doing this, assuming taking care of input validation separately, or leaving users, tell sas not error if try keep variable isn't there. can setting option dkricond = warn; or nowarn rather default of error.

if go down route, advise making note of previous setting before change option , changing after rest of macro has run.


Comments

Popular posts from this blog

How to understand 2 main() functions after using uftrace to profile the C++ program? -

c# - Update a combobox from a presenter (MVP) -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -