BookmarkSubscribeRSS Feed
Chichi
Calcite | Level 5
I was trying to run the following program found in SAS help:

data projects;
options nodate pageno=1 linesize=80 pagesize=60;
input Projid startdate date9. enddate date9.;
Duration=enddate-startdate;
datalines;
398 17oct1997 02nov1997
942 22jan1998 10mar1998
167 15dec1999 15feb2000
250 04jan2001 11jan2001
;

proc print data=projects;
format startdate enddate date9.;
title 'Days Between Project Start and Project End';
run;

But in my output the enddates are:

02nov2001
10mar2001
15feb2002
11jan2002

It seems that the system picked up the right day and month but not the year. And this only happens to the variable enddate but not the startdate.

Can someone help me to figure out why this is happening?

Thanks!
2 REPLIES 2
ieva
Pyrite | Level 9
Hi!

That is really interesting. For me SAS shows missing data (as I figured out, it starts reading eddate from column 14 not 15). So it works if I specify:

input Projid startdate date9. @15 enddate date9.;

It works also if informats are specified in such a way:

informat startdate date9. enddate date9.;
input Projid startdate enddate;

But I have no idea why it shows those wrong years for you.

Message was edited by: ieva
venkatesh
Calcite | Level 5
Hi.,

The Problem is[as u mentioned for variables startdate and enddate date9. informats, SAS will read from 10 column for Enddate and it is blank(null) so the values showing as missing data] space between the startdate and enddate.

If u will mentioned as follows it works fine.

17oct199712nov1997
22jan199810mar1998
15dec199915feb2000
04jan200111jan2001

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
  • 2 replies
  • 557 views
  • 0 likes
  • 3 in conversation