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;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!

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;

 

SAS For Dummies 3rd Edition! Check out the new edition, covering SAS 9.4, SAS Viya, and all of the modern ways to use SAS!
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.

hackathon24-white-horiz.png

The 2025 SAS Hackathon has begun!

It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.

Latest Updates

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 5 replies
  • 2357 views
  • 1 like
  • 4 in conversation