BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
learner3
Fluorite | Level 6
data kvb;

input date  withdraw balance;
datalines;

01-04-2022   .     671.00
08-04-2022  36.00 635.00
11-04-2022 72.00  563.00
16-04-2022 20.00  543.00
27-04-2022  30.00 513.00
27-04-2022  10.00 503.00
29-04-2022 75.00  428.00
29-04-2022  11.00 417.00
30-04-2022     .   517.0
;
run;

Screenshot (2).png

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisHemedinger
Community Manager

INFORMAT tells SAS how to interpret/read a raw value as it appears in the input source. FORMAT tells SAS how to display a raw value for appearance purposes. In this program you need both. I used DDMMYY10 here to match the input layout, but you could use DATE9. (ex: 08APR2022) if you prefer, as many people do with SAS.

 

data kvb;
input date withdraw balance;
informat date ddmmyy10.;
format date ddmmyy10.;
datalines;
01-04-2022 . 671.00
08-04-2022 36.00 635.00
11-04-2022 72.00 563.00
16-04-2022 20.00 543.00
27-04-2022 30.00 513.00
27-04-2022 10.00 503.00
29-04-2022 75.00 428.00
29-04-2022 11.00 417.00
30-04-2022 . 517.0
;
run;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.

View solution in original post

5 REPLIES 5
LinusH
Tourmaline | Level 20

You need to supply an informat to your date field.

Data never sleeps
learner3
Fluorite | Level 6
i tried

data kvb;
input date withdraw balance;
informat date ddmmyy10.;
datalines;

01-04-2022 . 671.00
08-04-2022 36.00 635.00
11-04-2022 72.00 563.00
16-04-2022 20.00 543.00
27-04-2022 30.00 513.00
27-04-2022 10.00 503.00
29-04-2022 75.00 428.00
29-04-2022 11.00 417.00
30-04-2022 . 517.0
;
run;
ChrisHemedinger
Community Manager

INFORMAT tells SAS how to interpret/read a raw value as it appears in the input source. FORMAT tells SAS how to display a raw value for appearance purposes. In this program you need both. I used DDMMYY10 here to match the input layout, but you could use DATE9. (ex: 08APR2022) if you prefer, as many people do with SAS.

 

data kvb;
input date withdraw balance;
informat date ddmmyy10.;
format date ddmmyy10.;
datalines;
01-04-2022 . 671.00
08-04-2022 36.00 635.00
11-04-2022 72.00 563.00
16-04-2022 20.00 543.00
27-04-2022 30.00 513.00
27-04-2022 10.00 503.00
29-04-2022 75.00 428.00
29-04-2022 11.00 417.00
30-04-2022 . 517.0
;
run;

 

Learn from the Experts! Check out the huge catalog of free sessions in the Ask the Expert webinar series.
learner3
Fluorite | Level 6
in output i got this
1 22736 . 671
2 22743 36 635
3 22746 72 563
4 22751 20 543
5 22762 30 513
6 22762 10 503
7 22764 75 428
8 22764 11 417
9 22765 . 517
andreas_lds
Jade | Level 19

@learner3 wrote:
in output i got this
1 22736 . 671
2 22743 36 635
3 22746 72 563
4 22751 20 543
5 22762 30 513
6 22762 10 503
7 22764 75 428
8 22764 11 417
9 22765 . 517

Exactly as expected, if you don't attach a format to a variable that could be a date, the number of days since 01Jan1960 is displayed.

Reading the docs about sas-dates is recommended before working with sas.

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

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
  • 5 replies
  • 1428 views
  • 1 like
  • 4 in conversation