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

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

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