Help using Base SAS procedures

code problems

Reply
N/A
Posts: 1

code problems

what does this code means?

(first.id and last.id)<1 and (first.id and last.id)<1"

<1 for what meanings?

part of the dataset:

id   day1

1   2000/01/01

1   2000/01/01

1   2001/12/15

1   2001/12/31

2   2005/03/04

2   2005/03/04

2   2005/05/06

2   2006/07/09

2   2006/08/09

3   2008/01/15

3   2009/05/25

3   2009/07/15

thank you~

Super User
Super User
Posts: 7,997

Re: code problems

This means less than, i.e. if (first.id and last.id) is less than 1.

Sybols are:

< less than

> greater than

<= less than or equal to

>= greater than or equal to

There are several others in the SAS help.

Super User
Posts: 10,048

Re: code problems

(first.id and last.id) only has two value either  0  or 1 . Therefore,   (first.id and last.id)<1 is the same with (first.id and last.id)=0

Super User
Posts: 5,518

Re: code problems

Ksharp,

You solved my earlier riddle, so here's a new one related to this question.  What does this statement do?

if a=1 or 2 then b=3 and c=4;

Yes, it will run without error.  But what does it do?

Super User
Posts: 10,048

Re: code problems

Posted in reply to Astounding

Hi, Astounding

That is an old scam . 2 is always be true , therefore a=1 or 2 is always be true too , you are going to execute the following statement always .Am I right ?

Xia Keshan

Super User
Posts: 5,518

Re: code problems

You're right about the IF condition.  What about the THEN result?

Super User
Posts: 10,048

Re: code problems

Posted in reply to Astounding

That is strange code , Can you explain it ?

Oh , I understood .

then b=(2 and c=2) ;

Super User
Posts: 11,343

Re: code problems

Posted in reply to Astounding

B is set to 0 (false) and if C doesn't exist you get a missing value for an uninitialized variable.

3 and c evaluates to false unless c = 4 then you get 3 and true (c=4) so true and true = true for B.

Super User
Posts: 5,518

Re: code problems

Good answer.

B will be 0 or 1, depending on the value of C.  "3" is always true.  So when C=4, B is set to 1.  For any other value of C (including missing), B is set to 0.

Ask a Question
Discussion stats
  • 8 replies
  • 370 views
  • 0 likes
  • 5 in conversation