BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
PSIOT
SAS Employee

Dear all,

i would like to add fill pattern in some vbar (BTT group) using dattrmap with proc sgplot.

Can you help me please for adding fill pattern in the code?

please find my code (graph in file enclosed):

 

data attrmap;
input id $ value $15. @22 fillcolor $10. @32 ;
datalines;
status Deceased (BTT) ygr
status Deceased (DT) ygr
status Transplanted bigb
status Ongoing (BTT) bio
status Ongoing (DT) bio
;
run;

/*ods select none;*/
ods graphics on;

ODS GRAPHICS / RESET IMAGENAME = 'HistoDuration' IMAGEFMT =png
HEIGHT = 5.2 in WIDTH = 6.2 in;
ODS LISTING GPATH = '\\vcarapp010\Rapports\01 - Pivotal study\01-Report\07-Communication\01-Intern Communication\01-Site Activity Report\Graphs' ;
ODS tagsets.sasreport13(ID=EGSR) gtitle;
proc sgplot data=statuspatient dattrmap=attrmap;
yaxis label='Support duration (days)' VALUES= (0 to 500 by 30);
vbar patient/ barwidth=0.3 response=nbSupportDay group=status attrid=status nooutline discreteoffset=0.1 datalabel ;
refline 180 / axis=y lineattrs=( color=darkgreen pattern=dash );
inset 'cumulative support duration= &supportDuration (year)' / position = topright;
run;

 

Regards,

 
 

 

1 ACCEPTED SOLUTION

Accepted Solutions
DanH_sas
SAS Super FREQ

FILLPATTERNS are not currently supported in discrete attrmaps, either through the attrmap data set or in the GTL language.

View solution in original post

15 REPLIES 15
PeterClemmensen
Tourmaline | Level 20

I think the closest you will get it to use the FILLSTYLE variable in the discrete attribute map data set. You can read more about it in the documentation.

 

However, I would simply use the FILLPATTERNATTRS option directly in the VBAR Statement

PSIOT
SAS Employee

Thanks for your answers.

 I don't know how to use FILLSTYLE? what are the options?

Using FILLPATTERNATTRS is difficult because I would like to put pattern in not all vbars.

 

Regards,

 

Reeza
Super User

1. Add a fillstyle column to the attribute map

2. Specify the pattern according to the methods outlined here:

https://documentation.sas.com/?docsetId=graphref&docsetTarget=p02daopdgx5yh4n1vmffk4ud4697.htm&docse...

 

data attrmap;
input id $ value $15. @22 fillcolor $10. @32 fillstyle ;
datalines;
status Deceased (BTT) ygr R1
status Deceased (DT) ygr  X2
status Transplanted bigb  L2
status Ongoing (BTT) bio X3
status Ongoing (DT) bio  
;
run;

Unfortunately I can't test any of this because you didn't provide sample data and I'm too lazy to make some up at the moment. If that doesn't work, post your log. You may need to modify the code above because I think the spacing was lost since you didn't use a code block when inserting your code - it won't be read in properly then. 

 


@PSIOT wrote:

Thanks for your answers.

 I don't know how to use FILLSTYLE? what are the options?

Using FILLPATTERNATTRS is difficult because I would like to put pattern in not all vbars.

 

Regards,

 


 

PSIOT
SAS Employee

Thanks Reeza for your answer,

I tried your code and unfortunately it doesn't work but unlike  previous versions there are some information in log file.

NOTE: The style element 'R1' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'X2' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'L2' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'X3' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'R1' in the option FILLATTRS is invalid. The default will be used.

Regards,

 

 

PSIOT
SAS Employee

Thanks Reeza for your answer,

I tried your code and unfortunately it doesn't work but unlike  previous versions there are some information in log file.

NOTE: The style element 'R1' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'X2' in the option FILLATTRS is invalid. The default will be used.
NOTE: The style element 'L2' in the option FILLATTRS is invalid. The default will be used.
....

Regards,

PSIOT

 

 

 

GraphGuy
Meteorite | Level 14

Here's a little something to get you started (I'm not sure it's got everything you'll need), and some simple data for others to use if they want to add some enhancements or alternate ideas...

 

data attrmap;
infile datalines dlm=',';
length id $10 value $15 fillcolor $10 fillpattern $10;
input id value fillcolor fillpattern;
datalines;
status,Deceased (BTT),ygr,R1
status,Deceased (DT),ygr,X2
status,Transplanted,bigb,L2
status,Ongoing (BTT),bio,X3
status,Ongoing (DT),bio,X3
;
run;

 

data statuspatient;
length status $15;
infile datalines dlm=',';
input patient nbSupportDay status;
datalines;
1,150,Transplanted
2,400,Ongoing (DT)
3,450,Ongoing (BTT)
4,100,Deceased (DT)
;
run;

 

ods graphics / attrpriority=none;
proc sgplot data=statuspatient dattrmap=attrmap;
yaxis label='Support duration (days)' VALUES= (0 to 500 by 30);
vbar patient/ barwidth=0.3 response=nbSupportDay group=status
attrid=status nooutline datalabel fillpattern;
refline 180 / axis=y lineattrs=( color=darkgreen pattern=dash );
yaxis label='Support duration (days)' VALUES= (0 to 500 by 100);
inset 'cumulative support duration=xxx (year)' / position = topright;
run;

 

bar_pattern.png

Reeza
Super User

@GraphGuy  Is there a reason FILLPATTERN isn't listed as an option for the discrete attribute maps dataset in the documentation? Is there a different reference that should be used?

 

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n18szqcwir8q2nn10od9hhdh2ksj.htm&doc...

 

https://documentation.sas.com/?docsetId=grstatproc&docsetTarget=n18szqcwir8q2nn10od9hhdh2ksj.htm&doc...

GraphGuy
Meteorite | Level 14

This is a new area for me, so I'm not sure (I just Google'd around, and trial-and-error'd, until I found what I needed). 

 

One of my fellow testers was having an in-depth look at the attrmap stuff this week, and I suspect he will find any remaining bugs/oddities, and also get the documentation enhanced, before the next release! 🙂

 

DanH_sas
SAS Super FREQ

FILLPATTERNS are not currently supported in discrete attrmaps, either through the attrmap data set or in the GTL language.

PSIOT
SAS Employee

Hello RobertAllison_SAS,

I tried your code but as others SAS users said, Fillpatterns are not currently supported in discrete attrmaps.

Please find an extract of log when I execute your code:

 

ods graphics / attrpriority=none;
56 proc sgplot data=statuspatient dattrmap=attrmap;
57 yaxis label='Support duration (days)' VALUES= (0 to 500 by 30);
58 vbar patient/ barwidth=0.3 response=nbSupportDay group=status
59 attrid=status nooutline datalabel fillpattern;
___________
1
WARNING 1-322: Assuming the symbol FILL was misspelled as fillpattern.
60 refline 180 / axis=y lineattrs=( color=darkgreen pattern=dash );
61 yaxis label='Support duration (days)' VALUES= (0 to 500 by 100);
62 inset 'cumulative support duration=xxx (year)' / position = topright;
63 run;

 

Regards,

PSIOT

GraphGuy
Meteorite | Level 14

Hmm ... my code runs cleanly for me at 9.4 maintenance 6 (ie, the latest release), and produces the output.

 

I guess we're back to the age-old question ... "which release of SAS are you using?"

(ODS Graphics is fairly new, and features are being added with each release, therefore the release you're using is very important.)

 

sas_log.png

PSIOT
SAS Employee

VERSION 9.4, it seems maintenace 3 or 4:

 

 

 

For Base SAS Software ...
Custom version information: 9.4_M3
Image version information: 9.04.01M3P062415
For SAS/STAT ...
Custom version information: 14.1
For SAS/GRAPH ...
Custom version information: 9.4_M3
For SAS Integration Technologies ...
Custom version information: 9.4_M3
For High Performance Suite ...
Custom version information: 2.2_M4
For SAS/ACCESS Interface to PC Files ...
Custom version information: 9.4_M3
For SAS/ACCESS Interface to ODBC ...
Custom version information: 9.4_M3

DanH_sas
SAS Super FREQ

Just to add another clarifying point, the FILLSTYLE column is synonymous with the FILLSTYLEELEMENT column. We deprecated the FILLSTYLE column name to make it clearer that this column should contain the names of ODS style elements from which you want to pull FILL attributes. The FILLSTYLE column name is still valid -- just deprecated.

 

 

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
  • 15 replies
  • 4852 views
  • 11 likes
  • 6 in conversation