BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Gieorgie
Quartz | Level 8

Hi everyone, I have a problem. I wanted to change the date format from as shown in the picture.

Gieorgie_0-1652862519878.png

to this.

Gieorgie_1-1652862572791.png

 

However, after using the format function, I get something like this. Why ? how to fix it

Gieorgie_2-1652862723106.png

 

my code:

data pap_wart;
set bmd.pap_wart_spr_202203;
keep kod_isin;
keep WBIL_BRUTTO_PLN;
keep WYCENA_ROZNICA_PLN;
keep data_emisji;
keep data_zap;
format data_zap yymmdd10.;
run;
1 ACCEPTED SOLUTION

Accepted Solutions
japelin
Rhodochrosite | Level 12

how about this code.

 

data pap_wart;
  set bmd.pap_wart_spr_202203;
  keep kod_isin
       WBIL_BRUTTO_PLN
       WYCENA_ROZNICA_PLN
       data_emisji
       data_zap;
  data_zap=datepart(data_zap); // <-insert
  format data_zap yymmdd10.;
run;

View solution in original post

2 REPLIES 2
japelin
Rhodochrosite | Level 12

how about this code.

 

data pap_wart;
  set bmd.pap_wart_spr_202203;
  keep kod_isin
       WBIL_BRUTTO_PLN
       WYCENA_ROZNICA_PLN
       data_emisji
       data_zap;
  data_zap=datepart(data_zap); // <-insert
  format data_zap yymmdd10.;
run;
Kurt_Bremser
Super User

Datetimes and times are counts of seconds in SAS, while dates are counts of days; so datetime = date * 86400.

 

Always keep this in mind when working with such values.

The functions you need for the conversions are

  • DATEPART - extracts the date from a datetime
  • TIMEPART - extracts the time from a datetime
  • DHMS - builds a datetime from a date, hours, minutes and seconds; to build a datetime from a date and a time, use DHMS(date,0,0,time)
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
  • 2 replies
  • 918 views
  • 1 like
  • 3 in conversation