FORMAT Procedure

Example 11: Creating a Format in a non-English Language

Features:
PICTURE statement options: :
DATATYPE=
LANGUAGE=
Other features:

LOCALE= system option

Details

This example does the following:
  • Creates picture formats using directives for formatting date and datetime values by using the DATATYPE= statement option.
  • Uses the LOCALE= system option to specify the locale for German.
  • Prints date and datetime values to the log in German using the picture formats.
  • Prints a datetime value in French to the log by using the picture format that specifies LANGUAGE=french.

Program

proc format;
   picture mdy(default=8) other='%0d%0m%Y' (datatype=date);
   picture langtsda (default=50) other='%A, %d %B, %Y' (datatype=date);
   picture langtsdt (default=50) other='%A, %d,%B, %Y %H %M %S' 
                                 (datatype=datetime);
   picture langtsfr (default=50) other='%A, %d %B, %Y %H %M %S' 
                                 (datatype=datetime language=french);
   picture alltest (default=100)
           other='%a %A %b %B %d %H %I %j %m %M %p %S %w %U %y %%' 
           (datatype=datetime);
run;
option locale = de_DE;
data _null_ ;
   a= 18903;
   b = 1633239000;
   put a= mdy.;
   put a= langtsda.;
   put b= langtsdt.;
   put b= langtsfr.;
   put b= alltest.;
run ;

Program Description

Create formats using the PICTURE statement.Each PICTURE statement specifies the date or datetime values to format using directives. %A prints a full weekday name. %B prints a full month name. %d prints the day of the month. %Y prints the year. %H prints the hour (24–hour clock). %M prints the minute. %S prints the seconds. The first three formats print the date or datetime in the language specified by the current value of the LOCALE= system option. The format langtsfr prints the datetime in French.For the remaining directives, see the PICTURE statement.
proc format;
   picture mdy(default=8) other='%0d%0m%Y' (datatype=date);
   picture langtsda (default=50) other='%A, %d %B, %Y' (datatype=date);
   picture langtsdt (default=50) other='%A, %d,%B, %Y %H %M %S' 
                                 (datatype=datetime);
   picture langtsfr (default=50) other='%A, %d %B, %Y %H %M %S' 
                                 (datatype=datetime language=french);
   picture alltest (default=100)
           other='%a %A %b %B %d %H %I %j %m %M %p %S %w %U %y %%' 
           (datatype=datetime);
run;
Set the LOCALE= system option.de_DE is the locale value for Germany.
option locale = de_DE;
Print date and datetime values in German and French.The DATA step prints to the SAS log the date and datetime information for 3 October, 2011, 05:30:00 AM. All values are written in German except for the value of b when it is formatted using the LANGTSFR format. The LANGSTSFR format prints the datetime value in French.
data _null_ ;
   a= 18903;
   b = 1633239000;
   put a= mdy.;
   put a= langtsda.;
   put b= langtsdt.;
   put b= langtsfr.;
   put b= alltest.;
run ;

The SAS Log Displaying Picture Format Output in German and French

148  proc format;
149     picture mdy(default=8) other='%0d%0m%Y' (datatype=date);
NOTE: Format MDY has been output.
150     picture langtsda (default=50) other='%A, %d %B, %Y' (datatype=date);
NOTE: Format LANGTSDA has been output.
151     picture langtsdt (default=50) other='%A, %d,%B, %Y %H %M %S' (datatype=datetime);
NOTE: Format LANGTSDT has been output.
152     picture langtsfr (default=50) other='%A, %d %B, %Y %H %M %S' (datatype=datetime
152! language=french);
NOTE: Format LANGTSFR has been output.
153     picture alltest (default=100)
154             other='%a %A %b %B %d %H %I %j %m %M %p %S %w %U %y %%' (datatype=datetime);
NOTE: Format ALLTEST has been output.
155  run;

NOTE: PROCEDURE FORMAT used (Total process time):
      real time           0.01 seconds
      cpu time            0.00 seconds


156
157  option locale = de_DE ;
158  data _null_ ;
159     a= 18903;
160     b = 1633239000;
161     put a= mdy.;
162     put a= langtsda.;
163     put b= langtsdt.;
164     put b= langtsfr.;
165     put b= alltest.;
166  run ;

a=03102011
a=Montag, 3 Oktober, 2011
b=Montag, 3,Oktober, 2011 5 30 0
b=Lundi, 3 octobre, 2011 5 30 0
b=Mo  Montag Okt Oktober 3 5 5 276 10 30 AM 0 2 40 11 %