Help using Base SAS procedures

Numeric Value vs Date Format

Reply
N/A
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;
run;

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.
Pappu.
SAS Super FREQ
Posts: 8,743

Re: Numeric Value vs Date Format

Hi:
There is quite a long explanation of date constants in this previous forum posting:
http://support.sas.com/forums/thread.jspa?messageID=10671⦯

...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:
[pre]
where period_end_date = '31Jan2009'd;
OR
where period_end_date = 17928;
[/pre]

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

cynthia
N/A
Posts: 0

Re: Numeric Value vs Date Format

Thanks for the explaination Cynthia and venkatesh!!!
Contributor
Posts: 61

Re: Numeric Value vs Date Format

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.;
cards;
120 12-12-2007
112 11-12-2008
113 31-1-2009
;
proc print;
format period_end_date date9.;
run;

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

Venky.
Ask a Question
Discussion stats
  • 3 replies
  • 127 views
  • 0 likes
  • 3 in conversation