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

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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
  • 550 views
  • 0 likes
  • 3 in conversation