Help using Base SAS procedures

DATE9. Formatting Not Working With Manually Created Dataset

Reply
Occasional Contributor
Posts: 5

DATE9. Formatting Not Working With Manually Created Dataset

[ Edited ]

I am making a mock data set. It doesn't like read in the dates.

Here is the first few lines with the first row:

data mockdata;

input LINK_I CARDNMBR DATE $ Date9. ACTIVE DELQs;

datalines;

1 1 30JUN2014 1 1

 

 

;

run;

 

In the output, it cuts off the last digit and gives 30JUN201  and it considers it a charater, not a date Smiley Sad

Super User
Posts: 19,814

Re: DATE9. Formatting Not Working With Manually Created Dataset

What does the $ imply in the input statement? 

Remove it for starters. 

Occasional Contributor
Posts: 5

Re: DATE9. Formatting Not Working With Manually Created Dataset

I thought you had to put that after a variable name to say its a character.

If I remove $  i.e. have:

 

data mockdata;

input LINK_I CARDNMBR DATE Date9. ACTIVE DELQs;

datalines;

1 1 30JUN2014 1 1

 

 

then the date value for first row is 19904. I don't want it to show as a number of days since 1960. I just want it to show as 30JUN2014.

If I remove "Date9." i.e. :

data mockdata;

input LINK_I CARDNMBR DATE ACTIVE DELQs;

datalines;

 

then the whole date column shows as missings (has ".")

Super User
Posts: 7,782

Re: DATE9. Formatting Not Working With Manually Created Dataset

Using a date informat does not automatically assign a display format to a variable; so you need a separate

format date date9.;

statement.

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
Super User
Posts: 10,028

Re: DATE9. Formatting Not Working With Manually Created Dataset

data mockdata;

input LINK_I CARDNMBR DATE : Date9. ACTIVE DELQs;

format date date9.;

datalines;

1 1 30JUN2014 1 1

 

Occasional Contributor
Posts: 5

Re: DATE9. Formatting Not Working With Manually Created Dataset

Thanks. This works.

Ask a Question
Discussion stats
  • 5 replies
  • 273 views
  • 1 like
  • 4 in conversation