BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
dxiao2017
Lapis Lazuli | Level 10

The picture format of the date/time should be %d%3b%Y:%HH (not %d%3B%Y:%HH), see the screen capture(p208,PG3 pdf):

 

Untitled1.png

 

The code and results are as follows.

 

date/time format is not correct:

proc format;
    picture dateh (default=13)
            low-high='%d%3B%Y:%HH'
            (datatype=datetime);
run;

Untitled2.png

date/time format is correct:

proc format;
    picture dateh (default=13)
            low-high='%d%3b%Y:%HH'
            (datatype=datetime);
run;

Untitled3.png

1 ACCEPTED SOLUTION

Accepted Solutions
Tom
Super User Tom
Super User

What is your session ENCODING setting?  The %3B will not work with Unicode session.

 

https://documentation.sas.com/doc/en/proc/1.0/p0n990vq8gxca6n1vnsracr6jp2c.htm

 

%b

abbreviated month name (for example, JAN or Jan). The character casing is determined by the SAS session locale.

Tip For the English language, to always create an abbreviated month with only an uppercase initial letter (for example, Jan), use the directive %3B.

%<n>B

the full month name (for example, January) if n is not included in the directive. n specifies the number of characters that appear for the month name. In comparison, the %b directive writes a three-character month abbreviation in uppercase letters for some locales.

Restrictions The directives argument is not supported if CASFMTLIB is specified.
n is not supported in DBCS and Unicode SAS sessions.
Example %3B would write Oct for the month of October

View solution in original post

7 REPLIES 7
Kathryn_SAS
SAS Employee

Can you clarify what documentation you are referencing?

dxiao2017
Lapis Lazuli | Level 10

Hi @Kathryn_SAS , the material is SAS Programming 3: Advanced Techniques Course Notes (PDF document), which I downloaded from the 7-days free trial, the version is 15May2019, LWPG3M6_001. Perhaps this mistake is only in the course note PDF and it is not in the online materials. The screen capture of the PDF page is as follows:

dxiao2017_0-1756229500441.png

dxiao2017
Lapis Lazuli | Level 10

Hi @Kathryn_SAS , sorry I forgot to tell that the code was from PG3 lesson 5's demo, p305d01, and it uses dataset pg3.storm_detail, according to the instruction, the complete code for this is as follows:

proc format;
    picture dateh (default=13)
            low-high='%d%3B%Y:%HH'
            (datatype=datetime);
run;

title 'Storms with Category 5 Winds';
proc print data=pg3.storm_detail noobs;
    var Name ISO_time Wind Pressure Region;
    where Wind>155; 
    format ISO_time dateh.;
run;
title;

and I got this output:

dxiao2017_0-1756236103411.png

however, the correct output in the materials is like this:

dxiao2017_1-1756236200299.png

and I can only get this output (above) after I change the format as %d%3b%Y, the code and output is as follows:

proc format;
    picture dateh (default=13)
            low-high='%d%3b%Y:%HH'
            (datatype=datetime);
run;

title 'Storms with Category 5 Winds';
proc print data=pg3.storm_detail noobs;
    var Name ISO_time Wind Pressure Region;
    where Wind>155; 
    format ISO_time dateh.;
run;
title;

dxiao2017_2-1756236521369.png

Tom
Super User Tom
Super User

What is your session ENCODING setting?  The %3B will not work with Unicode session.

 

https://documentation.sas.com/doc/en/proc/1.0/p0n990vq8gxca6n1vnsracr6jp2c.htm

 

%b

abbreviated month name (for example, JAN or Jan). The character casing is determined by the SAS session locale.

Tip For the English language, to always create an abbreviated month with only an uppercase initial letter (for example, Jan), use the directive %3B.

%<n>B

the full month name (for example, January) if n is not included in the directive. n specifies the number of characters that appear for the month name. In comparison, the %b directive writes a three-character month abbreviation in uppercase letters for some locales.

Restrictions The directives argument is not supported if CASFMTLIB is specified.
n is not supported in DBCS and Unicode SAS sessions.
Example %3B would write Oct for the month of October
dxiao2017
Lapis Lazuli | Level 10

Hi @Tom , thanks a lot for your information! I got this encoding information through the proc content output, and it is unicode:

dxiao2017_0-1756237415006.png

it looks like both %3b and %3B works, which display 3 character month name and full month name respectively, and perhaps what does not work is the number, 3, or I would like to say that if one only wants to display a 3 character month name or a full month name, the number, 3, is not needed. I tried the example again:

proc format;
    picture dateh (default=13)
            low-high='%d%b%Y:%HH'
            (datatype=datetime);
run;

title 'Storms with Category 5 Winds';
proc print data=pg3.storm_detail noobs;
    var Name ISO_time Wind Pressure Region;
    where Wind>155; 
    format ISO_time dateh.;
run;
title;

dxiao2017_1-1756238086174.png

 

proc format;
    picture dateh (default=13)
            low-high='%d%B%Y:%HH'
            (datatype=datetime);
run;

title 'Storms with Category 5 Winds';
proc print data=pg3.storm_detail noobs;
    var Name ISO_time Wind Pressure Region;
    where Wind>155; 
    format ISO_time dateh.;
run;
title;

dxiao2017_2-1756238474883.png

 

Tom
Super User Tom
Super User

What PROC CONTENTS presents is the encoding setting for the dataset, not the encoding setting for the current SAS session.   To see the session encoding setting get the system option ENCODING.

%put ENCODING=%SYSFUNC(GETOPTION(ENCODING));

But if you made that dataset using the same type of SAS session you are currently running then most likely your SAS session is also using UTF-8 as the encoding.  In which case the the %3B directive cannot be used, per the documentation I posted before.

dxiao2017
Lapis Lazuli | Level 10

exactly @Tom , it is UTF-8, I think you are right about the number, n, before the month's format does not work😀

%put encoding=%sysfunc(getoption(encoding));
 69         %put encoding=%sysfunc(getoption(encoding));
 encoding=UTF-8
 70         

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

Register Now

Autotuning Deep Learning Models Using SAS

Follow along as SAS’ Robert Blanchard explains three aspects of autotuning in a deep learning context: globalized search, localized search and an in parallel method using SAS.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 337 views
  • 3 likes
  • 3 in conversation