BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ratika2
Fluorite | Level 6
proc sgplot data= titanic ;

histogram passengers  /fillattrs=(color='red');

density cred /group=sex  lineattrs=(color= 'red' 'blue')

;run;

 

I need to give two different color to sex (male and female) .How to do give red color to male and blue color to female. 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Here is what  I got.

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         proc sgplot data=sashelp.heart;
 70         styleattrs datacolors=(red blue) datacontrastcolors=(red blue);
 71         histogram height /fillattrs=(color=red );
 72         density height/group=sex;
 73         run;
 
 NOTE: “PROCEDURE SGPLOT”所用时间(总处理时间):
       实际时间          0.17 秒
       用户 CPU 时间     0.09 秒
       系统 CPU 时间     0.02 秒
       内存              9018.00k
       OS 内存           34604.00k
       时间戳           2020-04-17 上午11:42:53
       Step Count                        114  Switch Count  5
       页错误数                       0
       页回收数                     1936
       页交换数                        0
       主动上下文切换数        1293
       被动上下文切换数      0
       块输入操作数            0
       块输出操作数           1624
       
 NOTE: 从数据集 SASHELP.HEART. 读取了 5209 个观测
 
 74         
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 86         

x.png

View solution in original post

5 REPLIES 5
Ksharp
Super User
proc sgplot data=sashelp.heart;
styleattrs datacolors=(red blue) datacontrastcolors=(red blue);
histogram height /fillattrs=(color='red');
density height/group=sex;
run;
ratika2
Fluorite | Level 6
Sorry, but its displaying syntax error. My query is regarding giving different colors to group variable in density plot. Giving lineattrs display only one color for both group variable. I need to display different colors to density plot line.
Jagadishkatam
Amethyst | Level 16

please try the bellow code

 

proc sgplot data= titanic ;
styleattrs datacolors=(red blue) datacontrastcolors=(red blue);
histogram passengers  /fillattrs=(color='red');
density cred /group=sex  ;
run;
Thanks,
Jag
Ksharp
Super User

Here is what  I got.

 
 1          OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 68         
 69         proc sgplot data=sashelp.heart;
 70         styleattrs datacolors=(red blue) datacontrastcolors=(red blue);
 71         histogram height /fillattrs=(color=red );
 72         density height/group=sex;
 73         run;
 
 NOTE: “PROCEDURE SGPLOT”所用时间(总处理时间):
       实际时间          0.17 秒
       用户 CPU 时间     0.09 秒
       系统 CPU 时间     0.02 秒
       内存              9018.00k
       OS 内存           34604.00k
       时间戳           2020-04-17 上午11:42:53
       Step Count                        114  Switch Count  5
       页错误数                       0
       页回收数                     1936
       页交换数                        0
       主动上下文切换数        1293
       被动上下文切换数      0
       块输入操作数            0
       块输出操作数           1624
       
 NOTE: 从数据集 SASHELP.HEART. 读取了 5209 个观测
 
 74         
 75         
 76         OPTIONS NONOTES NOSTIMER NOSOURCE NOSYNTAXCHECK;
 86         

x.png

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!

SAS Enterprise Guide vs. SAS Studio

What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.

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