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.
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
proc sgplot data=sashelp.heart;
styleattrs datacolors=(red blue) datacontrastcolors=(red blue);
histogram height /fillattrs=(color='red');
density height/group=sex;
run;
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;
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
thanks
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Get started using SAS Studio to write, run and debug your SAS programs.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.