Hi all,
I'm trying to append a single observation containing the value of a macro variable to an existing data set. My code (see below) works fine as long my input data set contains at least one observation, but fails if not.
Due to the context my program will run, I'm looking for a solution which works and
- ensures that type and length of data set variable VALUE in OUT is equal to INPUT
- does not need creating temporary data sets
Does anyone have an idea for a simple solution?
Many thanks!
Regards,
Stephan
/** sas code begin *******************************************/
%let mvar=test;
data INPUT; /*works */
length value $20;
value="obs1";
run;
data INPUT; /*works not*/
length value $20;
delete;
run;
data OUT;
set INPUT end=eof;
output;
if(eof) then do;
value=symget('mvar');
output;
end;
run;
/** sas code end *******************************************/