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
Post a Comment