Help using Base SAS procedures

Numeric Value vs Date Format

Not applicable
Posts: 0

Numeric Value vs Date Format

Hello All

In my data set I have a variable called "Period_End_Date". When I ran a Proc Contents on the dataset it see that the variable is listed as a numeric variable with date9. format.

data wps_dply.temp1;
set input.dataset;
where period_end_date=31-1-2009;

There are no error messages in the log however am not getting an output. The log is displaying a message saying:

NOTE: There were 0 observations read from the data set INPUT.DATASET.
WHERE period_end_date=((31-1)-2009);
NOTE: The data set WPS_DPLY.TEMP1 has 0 observations and 8 variables.

Can anybody tell me why I am not having any observations in my dataset?

Thanks for your help in advance.
Posts: 9,371

Re: Numeric Value vs Date Format

Posted in reply to deleted_user
There is quite a long explanation of date constants in this previous forum posting:⦯

...that may help you.

The bottom line is that you have to use or ask for the date in the form that SAS expects...either as the date in number form for the where clause or the date as a date constant for the where clause:
where period_end_date = '31Jan2009'd;
where period_end_date = 17928;

The first example is a date constant, which is easier to read and to change. The second example is the "number" 17928 because Jan 31, 2009 is 17,928 days from Jan 1, 1960 (which represents a 0 in the SAS date time line).

For example, if Jan 1 1960 = 0 then here are some other date values shown as how they are internally stored by SAS:

-3334 = 15Nov1950
-365 = 01Jan1959
0 = 01Jan1960
1 = 02Jan1960
2 = 03Jan1960
74 = 15Mar1960
3683 = 31Jan1970
17928 = 31Jan2009
17982 = 26Mar2009

Not applicable
Posts: 0

Re: Numeric Value vs Date Format

Posted in reply to Cynthia_sas
Thanks for the explaination Cynthia and venkatesh!!!
Posts: 61

Re: Numeric Value vs Date Format

Posted in reply to deleted_user
Hi Pappu,

here in your dataset variable period_end_date in the form of date9. format, so u have to give
where period_end_date='31jan2009'd; run;

here is example

data date;
input a period_end_date ddmmyy10.;
120 12-12-2007
112 11-12-2008
113 31-1-2009
proc print;
format period_end_date date9.;

data test;
set date;
where period_end_date='31jan2009'd
proc print;

Ask a Question
Discussion stats
  • 3 replies
  • 3 in conversation