BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
3 REPLIES 3
Cynthia_sas
SAS Super FREQ
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
deleted_user
Not applicable
Thanks for the explaination Cynthia and venkatesh!!!
venkatesh
Calcite | Level 5
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.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 692 views
  • 0 likes
  • 3 in conversation