Hi all,
I should use the proc means in a particular way: n-1 values are stored in a DS (e.g. DS1) the last value is passed by a macro variable.
How can I do without writing the last value into the DS?
%let outvalue=5;
PROC MEANS DATA=DS1 noprint
;
class
id;
VAR x
; /*and the value stored in the macro variable &outvalue*/
OUTPUT OUT=outfile(drop=_TYPE_ _FREQ_) median
=mymedian;
RUN
Thank you
Simone
What do you mean by "the last value"?
Please attach some example data and desired output.
/Linus
Try after you get those results of PROC MEANS doing the following:
* select the value of your macro variable;
data _null_;
set DS1;
call symput('outvalue', mymedian);
run;
%Put outvalue is &outvalue;
*keep only n-1 observations to DS1 data set;
data DS1;
set DS1 end=last;
if last then delete;
run;
Still don't get the point.
I was running your PROC MEANS with sashelp.class (class age), and then you want to delete 16-year olds. Why?
And still don't understand the use of &outvalue. Your are creating it, but not using it...?
I don't think there is an option in PROC MEANS to delete the last row.
But you could merge your two data steps:
...
if last then do;
call symput('outvalue',mymedian);
delete;
end;
...
/Linus
Then View is a good choice.
%let outvalue=5;
data want/view=want;
set ds1;
outvalue=&outvalue;
run;
Ksharp
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.