Help using Base SAS procedures

Proc means: can I use it in this manner?

Reply
Occasional Contributor
Posts: 19

Proc means: can I use it in this manner?

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

Super User
Posts: 5,255

Proc means: can I use it in this manner?

What do you mean by "the last value"?

Please attach some example data and desired output.

/Linus

Data never sleeps
Frequent Contributor
Posts: 82

Proc means: can I use it in this manner?

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;

Super User
Posts: 5,255

Proc means: can I use it in this manner?

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
Super User
Posts: 9,671

Proc means: can I use it in this manner?

Then View is a good choice.

%let outvalue=5;

data want/view=want;

set ds1;

outvalue=&outvalue;

run;

Ksharp

Ask a Question
Discussion stats
  • 4 replies
  • 141 views
  • 0 likes
  • 4 in conversation