40.SPECIAL WHERE OPERATORS

                       SPECIAL WHERE OPERATORS

--->THERE ARE SOME SPECIAL OPERATORS IN  SAS FOR SUBSETTING THE VARIABLES..THEY ARE

-->BETWEEN-AND

-->IS NULL 

-->IS MISSING

-->CONTAINS


-->BETWEEN-AND OPERATOR:

DATA A16;

SET SASUSER.CLASS2;

WHERE AGE BETWEEN 12 AND 14;

RUN;

PROC PRINT;

RUN;


LOG:

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

      WHERE (AGE>=12 and AGE<=14);

NOTE: The data set WORK.A16 has 12 observations and 7 variables.

NOTE: DATA statement used (Total process time):

      real time           0.59 seconds

      cpu time            0.03 seconds


NOTE: Writing HTML Body file: sashtml.htm

NOTE: There were 12 observations read from the data set WORK.A16.

NOTE: PROCEDURE PRINT used (Total process time):

      real time           1.78 seconds

      cpu time            0.21 seconds


RESULT:

Obs Name Sex Age Height Weight DOB CLASS
1 Alfred M 14 69 112.5 12/10/2009 9
2 Alice F 13 56.5 84 12/03/2010 8
3 Barbara F 13 65.3 98 14/12/2010 8
4 Carol F 14 62.8 102.5 12/11/2009 9
5 Henry M 14 63.5 102.5 14/11/2009 9
6 James M 12 57.3 83 15/03/2011 7
7 Jane F 12 59.8 84.5 17/04/2011 7
8 Jeffrey M 13 62.5 84 15/04/2010 8
9 John M 12 59 99.5 15/06/2011 7
10 Judy F 14 64.3 90 18/12/2010 9
11 Louise F 12 56.3 77 14/11/2011 7
12 Robert M 12 64.8 128 14/12/2011 7


-->IS NULL OPERATOR:

DATA A17;

SET SASHELP.CLASS;

WHERE NAME IS NULL;

RUN;

PROC PRINT;

RUN;


LOG:

NOTE: There were 4 observations read from the data set SASHELP.CLASS.
      WHERE NAME is null;
NOTE: The data set WORK.A17 has 4 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.09 seconds
      cpu time            0.00 seconds


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


RESULT:

Obs Name Sex Age Height Weight
1   M 12 57.3 83.0
2   M 12 59.0 99.5
3   F 13 56.5 84.0
4   F 15 66.5 112.0


-->IS MISSING OPERATOR:


DATA A18;

SET SASHELP.CLASS;

WHERE NAME IS MISSING;

RUN;

PROC PRINT;

RUN;


LOG:

NOTE: There were 4 observations read from the data set SASHELP.CLASS.
      WHERE NAME is null;
NOTE: The data set WORK.A18 has 4 observations and 5 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds

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


RESULT:

Obs Name Sex Age Height Weight
1   M 12 57.3 83.0
2   M 12 59.0 99.5
3   F 13 56.5 84.0
4   F 15 66.5 112.0


-->CONTAINS OPERATOR:
 

DATA A19;

SET SASUSER.CLASS2;

WHERE NAME CONTAINS 'James';

RUN;

PROC PRINT;

RUN;


LOG:

NOTE: There were 1 observations read from the data set SASUSER.CLASS2.
      WHERE NAME contains 'James';
NOTE: The data set WORK.A19 has 1 observations and 7 variables.
NOTE: DATA statement used (Total process time):
      real time           0.01 seconds
      cpu time            0.01 seconds


NOTE: There were 1 observations read from the data set WORK.A19.
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 James M 12 57.3 83 15/03/2011 7


--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