From: Jay on 28 May 2010 15:00 Hi: I have a macro function called output that takes a dataset as argument and i have datasets: dataset_1a, dataset_2a, etc, and I want to call that macro with the corresponding dataset name and store the result as new variable in xx1. data xx; set xx1; array vars{3} (1,2,3); array chars{3}$ ('a','b','c'); do i = 1 to dim(vars); do j=1 to dim(vars) tmp = %output(input=dataset_vars(i)chars(j)); end; drop tmp; run; and SAS is giving me: ERROR: Invalid option name x(whatever i is) how can i fix this? thank you
From: Tom Abernathy on 29 May 2010 01:49 Jay - Unless your macro is simply doing string manipulations on the name of the data set that you probably can't do that. If it does just do string manipulations (no PROC or DATA steps) then you might be able to do it using the RESOLVE function. Your data step code also looks strange. I am not sure why you are using an array to loop over a range of values when the DO statement does that already. Also the concatenation character in SAS is || (or !! depending on your character set). Or you could use one of the CAT functions if you are using SAS 9.xx. data new ; do var='1','2','3'; do char='a','b','c'; tmp = resolve('%output(input=dataset_'||var||char||')'); output; end; end; run; On May 28, 3:00 pm, Jay <jingsi....(a)gmail.com> wrote: > Hi: > I have a macro function called output that takes a dataset as > argument and i have datasets: dataset_1a, dataset_2a, etc, and I want > to call that macro with the corresponding dataset name and store the > result as new variable in xx1. > > data xx; > set xx1; > array vars{3} (1,2,3); > array chars{3}$ ('a','b','c'); > do i = 1 to dim(vars); > do j=1 to dim(vars) > tmp = %output(input=dataset_vars(i)chars(j)); > end; > drop tmp; > run; > > and SAS is giving me: ERROR: Invalid option name x(whatever i is) > > how can i fix this? thank you
|
Pages: 1 Prev: Using LIFEREG estimates for CDF/PDF Next: sorting html tables |