Thanks for your response What if I have non-trivial variable names such as a, b, c, and d data have; input varName$ a b c d; cards; a . . . . c . . . . d . . . . ; run; Is there an efficient way to do that? Thanks again for your help.
... View more
Dear SAS experts, I'm wondering if there is an easy way to use the value a variable to directly refer to other variables. For example, given the data set below data have; input varIndex var_1 var_2 var_3 var_4; cards; 1 . . . . 3 . . . . 2 . . . . ; run; I would like to assign 1 to var_i where i is given by the value of varIndex such that the desired output will be data want; input varIndex var_1 var_2 var_3 var_4; cards; 1 1 . . . 3 . . 1 . 2 . 1 . . ; run; I've tried data want; set have; array varArray (4) var_1 - var_4; do i = 1 to 4; if i = varIndex then varArray(i) = 1; end; run; and it worked. I'm wondering instead of using a do loop to search for the variable I want to refer, is there a more efficient and direct way (e.g. if I have var_1 - var_100000) to achieve that? Thanks for your help.
... View more
Hi everyone, I'm trying to merge two datasets, ds1 and ds2, and create columns to indicate the source of each row in the output dataset, dsout. For example, data dsout; merge ds1 (in=a) ds2 (in=b); by var; from_ds1 = a; from_ds2 = b; run; I'm wondering if there's a simple way to do that by proc sql Thanks for your help.
... View more
Hi everyone, Is it possible to clear log, clear output, close all viewtable and run the script in one key (dmkey)? I currently define my F3 as clear log; clear output; submit; which is not able to close all viewtables. Thanks for your help.
... View more
Hi everyone, I'm trying to find the non duplicated rows of certain columns from a data set using proc sort. For example, finding the unique combination of MAKE, TYPE, and ORIGIN in sashelp.cars Here is my code proc sort data=sashelp.cars (keep=MAKE TYPE ORIGIN) out=dsout noduprec; by MAKE TYPE; run; However, the resulting data set still contains duplicated rows. Can anyone explain to me why my code doesn't work as expect? Thanks for your help.
... View more