☑ This topic is solved.
Need further help from the community? Please
sign in and ask a new question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Posted 07-09-2024 03:32 PM
(1037 views)
Is it possible to use a picture format for the values a time axis?
In my test, it does not work.
proc format ;
picture monyyd (default=6) low - high = '%b-%y' (datatype=date);
run;
data class;
set sashelp.class;
if sex='M' then month='01MAR2024'd;
else month='01APR2024'd;
monthc=put(month,monyyd.);
run;
proc sgplot data=class;
vbarbasic monthc / response=height stat=mean;
run;
proc sgplot data=class;
vbarbasic month / response=height stat=mean;
xaxis values=('01MAR2024'd to '01APR2024'd by month)
type=time
interval=month
valuesformat=monyy5.;
run;
proc sgplot data=class;
vbarbasic month / response=height stat=mean;
xaxis values=('01MAR2024'd to '01APR2024'd by month)
type=time
interval=month
valuesformat=monyyd.;
run;
1 ACCEPTED SOLUTION
Accepted Solutions
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
5 REPLIES 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Mmm things seem odd indeed.
I conducted a few more tests, and the picture format seems to be misinterpreted.
proc format ;
picture monyyd (default=6) low - high = '%b-%y' (datatype=date);
run;
ods graphics on / width=5cm height=3cm;
data CLASS;
set SASHELP.CLASS;
if SEX='M' then MONTH='01MAR2024'd;
else MONTH='01APR2024'd;
MONTHC=put(MONTH,monyyd.);
run;
proc sgplot data=CLASS;
vbarbasic MONTHC / response=HEIGHT stat=mean;
run;
title 'format monyy.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month;
format MONTH monyy.;
run;
title 'valuesformat monyy.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month
valuesformat=monyy.;
run;
title 'format valuesformat monyy.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month
valuesformat=monyy.;
format MONTH monyy.;
run;
title 'format monyyd.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month;
format MONTH monyyd.;
run;
title 'valuesformat monyyd.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month
valuesformat=monyyd.;
run;
title 'format valuesformat monyyd.';
proc sgplot data=CLASS;
vbarbasic MONTH / response=HEIGHT stat=mean;
xaxis values = ('01MAR2024'd to '01APR2024'd by month)
type = time
interval= month
valuesformat=monyyd.;
format MONTH monyyd.;
run;
I also tried with datetime values as the confusing
NOTE: Time axis can only support date time values. The axis type will be changed to LINEAR.
message implies, to no avail.
Another confusing message is
NOTE: Since no format is assigned, the numeric category variable will use the default of BEST6.
that appears even though a format is defined.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
I'd contact tech support if no one answers here. This is strange.
Please keep this post updated if you do. 🙂
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
That's a crazy shortcoming of ODS graphics. Even some SAS formats are unsupported after all these years it's been around! How did the developers get away with that?
Here's the link https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0mwk2su1mw8bnn1f6xonfde64h5.htm
Here's the link https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0mwk2su1mw8bnn1f6xonfde64h5.htm
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
You can try this "workaround":
proc format ;
picture monyyd (default=6) low - high = '%b-%y' (datatype=date);
run;
data class;
set sashelp.class;
if sex='M' then month='01MAR2024'd;
else month='01APR2024'd;
monthc=put(month,monyyd.);
run;
%macro looper(d,n,f=best12.);
%do i = 0 %to &n.-1;
"%Sysfunc(intnx(month,&d.,&i.),&f.)"
%end;
%mend looper;
proc sgplot data=class;
vbarbasic month / response=height stat=mean;
xaxis
values=(%looper('01MAR2024'd,2))
VALUESDISPLAY=(%looper('01MAR2024'd,2,f=monyyd.))
;
run;
Bart
_______________
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation
Polish SAS Users Group: www.polsug.com and communities.sas.com/polsug
"SAS Packages: the way to share" at SGF2020 Proceedings (the latest version), GitHub Repository, and YouTube Video.
Hands-on-Workshop: "Share your code with SAS Packages"
"My First SAS Package: A How-To" at SGF2021 Proceedings
SAS Ballot Ideas: one: SPF in SAS, two, and three
SAS Documentation