37.COMPARISON OPERATORS

                      COMPARISON OPERATORS

--> IN SAS THERE ARE COMPARISON OPERATORS AND THEY ARE USED FOR SUBSETTING OBSERVATIONS...

(=,^=,GT,LT,GE,LE,IN)

EQUAL : =

NOT EQUAL : ^=

GREATER THAN : GT

LESSER THAN : LT

GREATER THAN EQUAL TO : GE

LESSER THAN EQUAL TO : LE

IN : IN


EQUAL (=,EQ)AND NOTEQUAL (NE,^=) OPERATORS:


DATA A6;

SET SASUSER.CLASS2;

WHERE AGE EQ 15 AND SEX NE "F";

RUN;

PROC PRINT;

RUN; 


LOG:


NOTE: There were 2 observations read from the data set SASUSER.CLASS2.
      WHERE (AGE=15) and (SEX not = 'F');
NOTE: The data set WORK.A6 has 2 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds



NOTE: Writing HTML Body file: sashtml.html

NOTE: There were 2 observations read from the data set WORK.A6.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.35 seconds
      cpu time            0.21 seconds

RESULT:

Obs Name Sex Age Height Weight DOB CLASS
1 Ronald M 15 67 133 12/03/2009 10
2 William M 15 66.5 112 15/02/2009 10


GREATER THAN (GT) AND LESSER THAN  (LT) OPERATORS:


DATA A7;

SET SASUSER.CLASS2;

WHERE AGE GT 12 AND CLASS LT 9;

RUN;

PROC PRINT;

RUN;


LOG:


NOTE: There were 3 observations read from the data set SASUSER.CLASS2.

      WHERE (AGE>12) and (CLASS<9);

NOTE: The data set WORK.A7 has 3 observations and 7 variables.

NOTE: DATA statement used (Total process time):

      real time           0.12 seconds

      cpu time            0.01 seconds


NOTE: There were 3 observations read from the data set WORK.A7.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.06 seconds

      cpu time            0.00 seconds


RESULT:

Obs Name Sex Age Height Weight DOB CLASS
1 Alice F 13 56.5 84 12/03/2010 8
2 Barbara F 13 65.3 98 14/12/2010 8
3 Jeffrey M 13 62.5 84 15/04/2010 8


GREATER THAN EQUAL TO (GE) AND LESSER THAN EQUAL TO (LE) OPERATORS:


DATA A8;

SET SASUSER.CLASS2;

WHERE AGE GE 12 AND HEIGHT LE 60;

RUN;

PROC PRINT;

RUN;


LOG:


NOTE: There were 5 observations read from the data set SASUSER.CLASS2.

      WHERE (AGE>=12) and (HEIGHT<=60);

NOTE: The data set WORK.A8 has 5 observations and 7 variables.

NOTE: DATA statement used (Total process time):

      real time           0.01 seconds

      cpu time            0.01 seconds


NOTE: There were 5 observations read from the data set WORK.A8.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           0.06 seconds

      cpu time            0.01 seconds


RESULT:

Obs Name Sex Age Height Weight DOB CLASS
1 Alice F 13 56.5 84 12/03/2010 8
2 James M 12 57.3 83 15/03/2011 7
3 Jane F 12 59.8 84.5 17/04/2011 7
4 John M 12 59 99.5 15/06/2011 7
5 Louise F 12 56.3 77 14/11/2011 7


IN (IN) OPERATOR:


DATA A9;

SET SASUSER.CLASS2;

WHERE CLASS IN(9,10);

RUN;

PROC PRINT;

RUN;

LOG:

NOTE: There were 8 observations read from the data set SASUSER.CLASS2.
      WHERE CLASS in (9, 10);
NOTE: The data set WORK.A9 has 8 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


NOTE: There were 8 observations read from the data set WORK.A9.
NOTE: PROCEDURE PRINT used (Total process time):
      real time           0.03 seconds
      cpu time            0.00 seconds

RESULT:

Obs Name Sex Age Height Weight DOB CLASS
1 Alfred M 14 69 112.5 12/10/2009 9
2 Carol F 14 62.8 102.5 12/11/2009 9
3 Henry M 14 63.5 102.5 14/11/2009 9
4 Janet F 15 62.5 112.5 14/11/2009 10
5 Judy F 14 64.3 90 18/12/2010 9
6 Mary F 15 66.5 112 15/12/2009 10
7 Ronald M 15 67 133 12/03/2009 10
8 William M 15 66.5 112 15/02/2009 10


--PLEASE FOLLOW THE BLOG FOR MORE UPDATES...

--FOLLOW US IN FACEBOOK SASALL4YOU AND JOIN ...

--JOIN US IN FACEBOOK AND TELEGRAM  CHANNEL FOR MORE UPDATES

   CLICK HERE: https://t.me/SasAll4You


Comments