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;
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;
You need to supply an informat to your date field.
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;
@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.
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!
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.