BookmarkSubscribeRSS Feed
HDSimo
Calcite | Level 5

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

4 REPLIES 4
LinusH
Tourmaline | Level 20

What do you mean by "the last value"?

Please attach some example data and desired output.

/Linus

Data never sleeps
ieva
Pyrite | Level 9

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;

LinusH
Tourmaline | Level 20

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

Data never sleeps
Ksharp
Super User

Then View is a good choice.

%let outvalue=5;

data want/view=want;

set ds1;

outvalue=&outvalue;

run;

Ksharp

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

What is Bayesian Analysis?

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 4 replies
  • 1624 views
  • 0 likes
  • 4 in conversation