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)

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

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
  • 2 replies
  • 261 views
  • 1 like
  • 3 in conversation