Help using Base SAS procedures

SAS help example error

Reply
N/A
Posts: 1

SAS help example error

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!
Frequent Contributor
Posts: 82

Re: SAS help example error

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
Contributor
Posts: 61

Re: SAS help example error

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
Ask a Question
Discussion stats
  • 2 replies
  • 106 views
  • 0 likes
  • 3 in conversation