Help using Base SAS procedures

Min Function Error

Reply
Frequent Contributor
Posts: 117

Min Function Error

Hi there,

I keep getting an error for the following code ->  Function MIN requires a numeric expression as argument 1.

Code:

proc sql;

create table  TEST as

select     ID,

              min(min(FIRST_Date, information_date)) as First_V2,

              max(LAST_Date)as Last_V2

from          base

group by      ID;

quit;

Can someone tell me what I am doing wrong?

PROC Star
Posts: 7,362

Re: Min Function Error

Was there more to the error message, specifically, something like one of the variables wasn't found in the table?

Frequent Contributor
Posts: 117

Re: Min Function Error

Hi Art, just one more line after that message :

ERROR: The following columns were not found in the contributing tables: First_V2.

but I don't get this line as this is the variable I am creating using the min statement?

PROC Star
Posts: 7,362

Re: Min Function Error

I would look at the log more closely.  I would guess that it would be stipulating either first_date, last_date, or information_date.  One of those appears to not exist in your data.  If you do a proc contents on the input data do all three show up?

Trusted Advisor
Posts: 2,113

Re: Min Function Error

Vomer,

Your error is in the syntax for the summary function min.  You have used the syntax for the MIN function from the DATA step instead of the summary function syntax required by PROC SQL.

The summary function MIN has one argument, not two.  Review the documentation in the PROC SQL manual.  You got it right for the MAX summary function, but I can't tell what you are trying to do in the expression that starts "min(min(" .

Doc Muhlbaier

Duke

Frequent Contributor
Posts: 117

Re: Min Function Error

all those data set exist guys. I am trying to get the cumulative min of the 2 variables : FIRST_Date, information_date

If I just do min (FIRST_Date, information_date) then it does not give me that which is why I tried the min (min() approach... but it is not working Smiley Sad

Super User
Super User
Posts: 6,499

Re: Min Function Error

It is telling you the FIRST_DATE is a character variable.

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