Monday
StudentSASLearn
Obsidian | Level 7
Member since
01-06-2025
- 14 Posts
- 6 Likes Given
- 0 Solutions
- 0 Likes Received
-
Latest posts by StudentSASLearn
Subject Views Posted 413 a week ago 1411 2 weeks ago 1419 2 weeks ago 1431 2 weeks ago 1463 2 weeks ago 1483 2 weeks ago 1566 3 weeks ago 1646 3 weeks ago 1735 3 weeks ago 919 01-09-2025 12:05 AM -
Activity Feed for StudentSASLearn
- Liked Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. for Ksharp. Monday
- Liked Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. for Ksharp. Sunday
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. a week ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 2 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 2 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 2 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 2 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 2 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 3 weeks ago
- Posted Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 3 weeks ago
- Liked Re: How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. for Ksharp. 3 weeks ago
- Posted How to Display the Counts in the Discrete Legends for Box Plot in Proc Template. on Graphics Programming. 3 weeks ago
- Liked Re: Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) for Tom. 02-04-2025 05:32 PM
- Posted Re: Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) on SAS Programming. 01-09-2025 12:05 AM
- Liked Re: Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) for Tom. 01-09-2025 12:04 AM
- Liked Re: Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) for Ksharp. 01-09-2025 12:03 AM
- Posted Re: Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) on SAS Programming. 01-09-2025 12:02 AM
- Posted Is there option in PROC COMPARE not to show difference in Lengths of Var (attributes) on SAS Programming. 01-08-2025 09:06 PM
- Posted Re: How to Display Counts Inside the Graphs Proc Template on Graphics Programming. 01-07-2025 04:32 PM
- Posted How to Display Counts Inside the Graphs Proc Template on Graphics Programming. 01-06-2025 11:21 PM
-
Posts I Liked
Subject Likes Author Latest Post 1 2 2 2 1
a week ago
I think you can use DATASYMBOLS option at begin grraph statement like @Ksharp colors options.
... View more
2 weeks ago
Oh completely forgot that. Sorry. Thank you for point out. Thought it was taking the different grouping into the boxplot for some reason. I can not thank you enough.🙏
... View more
2 weeks ago
Thank you @DanH_sas for your response. I think @Ksharp answered a similar question about displaying the N in response to another member. I was thinking more of using proc template ( as I came so far into this, otherwise I am happy with using SGPLOT or PANEL). I think at least I am stuck at bringing the same color legends into one column without affecting the graph.
... View more
2 weeks ago
Thank you @Ksharp . I think when we try to change the group or color, the values change . I don't know enough, but the value for the TRUCK-ASIA seems bar length changed in different versions.
... View more
2 weeks ago
Thank you again @Ksharp . Adding Dan, if we can refine it, I can see a lot of responses from him, while searching here for the answer @DanH_sas can you please help. 1. Is there a way I can keep colors of the Bars remains same, but change the patterns based on the 'Cartype' Like Asia (orange)-- and three 'Cartypes' have three different patterns, Europe is Pink and have same pattern as Asian Cartypes. 2. Create a Discreet legend where all Asia comes in one column, Europe comes in one column and same for USA. Thank you for your help
... View more
2 weeks ago
Thank you for clarifying all my questions. You are diamond filled with sas knowledge. I really appreciate your time .
... View more
3 weeks ago
Hi @Ksharp . Thank you very much. You guys are SAS AIs. Do much faster and perfectly. I will wait if @tc refines or gives any suggestions. Otherwise, I am happy with the output and will mark it as a Solution. However, I have two questions about the code. If it's not inconvenient, can you please shed some light on it? 1. At the following step, can I create the macro variable for count that you did in SGPLOT and present it (N= &x1.)? Will it be dynamic, or will it cause me any problems? value "SUV-Asia(N=25)" / lineattrs=(color=orange ) markerattrs=(color=blue symbol=diamond) ; This is Resolved I was able to do it. 2. I see you using two macros , I don't see these are local macros, are those available everyone with SAS 9.4 like default macros? if not can you please direct a link where I can read about please. thank you again for your time. %SGRECTANGLE %sganno
... View more
3 weeks ago
Thank you very much for your response. Is it possible to do in proc template? Or impossible?. Also can we make each region same color but different pattern in patterns and contrast color options.You have very great knowledge.
... View more
3 weeks ago
I am Learning the proc template. I tried to create a box plot with sashelp.cars. I've got to make it 80% of what I am thinking , I am stuck at the last 20 % to finish. Looking for help. My code creates graph correctly but stuck at creating the legend. Present graph only show the group legends text in legends, but 1. I want to add the number of to the legends text to display the counts. like (SUV-Asia (N= 25)). I tried creating the macro variable for counts and attach to the group., but it messing up my graph. 2. Is it possible to to diplay all the Asia related in one column, USA in another column, and Europe in another columns in Legends Here is my cars code *create data;
proc sql;
create table car_subjects as
select distinct
cats(Make, "-", Model) as USUBJID length=50,
Type as CarType length=15,
Origin as Region length=15,
Horsepower,
Weight,
MPG_City,
MPG_Highway,
MSRP
from sashelp.cars
where Make is not null and Model is not null;
quit;
*get Count to display in legend;
proc sql;
create table car_counts as
select CarType, Region, count(*) as N
from car_subjects
group by CarType, Region;
quit;
* Add count to dataset;
proc sort data=car_subjects;
by CarType Region;
run;
proc sort data=car_counts;
by CarType Region;
run;
/* Step 4: Merge and build final dummy dataset */
*try with few groups first;
data dummy_cars_final ( where = (region in ('USA' 'Asia' 'Europe') and cartype in ('SUV' 'Sedan' 'Truck')));
merge car_subjects(in=a) car_counts;
by CarType Region;
if a;
/* Derived variables */
region_type = catx("-", CarType, Region);
Score = round(40 + ranuni(0)*60, 0.1);
PowerIndex = round((Horsepower * 0.6 + Weight * 0.0005), 0.1);
EcoScore = round((MPG_City * 0.4 + MPG_Highway * 0.6), 0.1);
length LuxuryLevel $10;
if MSRP > 50000 then LuxuryLevel = "High";
else if MSRP > 30000 then LuxuryLevel = "Medium";
else LuxuryLevel = "Low";
drop Horsepower Weight MPG_City MPG_Highway MSRP;
run;
proc template;
define statgraph boxplot_template;
begingraph;
discreteattrmap name="comboMap" / ignorecase=true;
value "SUV-Asia" / fillattrs=(color=orange);
value "SUV-Europe" / fillattrs=(color=orange) ;
value "SUV-USA" / fillattrs=(color=orange) ;
value "Sedan-Asia" / fillattrs=(color=magenta) ;
value "Sedan-Europe" / fillattrs=(color=orange);
value "Sedan-USA" / fillattrs=(color=magenta);
value "Truck-Asia" / fillattrs=(color=grey) ;
value "Truck-USA" / fillattrs=(color=grey);
enddiscreteattrmap;
discreteattrvar attrvar=patgroup var=region_type attrmap='comboMap';
layout lattice / rows=2 columns=1 columndatarange=union ROWWEIGHTS=(.75 .25) ;
layout overlay /
xaxisopts=(label="Region" labelattrs=(size=12pt weight=bold)
tickvalueattrs=(size=12pt weight=bold))
yaxisopts=(offsetmin=0.05 offsetmax=0.05 label="Rating Score"
linearopts=(tickvaluesequence=(start=0 end=100 increment=10)));
boxplot x=region y=score /
name='BoxLegend'
group=patgroup
groupdisplay=cluster
boxwidth=0.6 clusterwidth=0.5
display=( median mean caps fillpattern )
medianattrs=(pattern=1);
endlayout;
discretelegend 'BoxLegend' /
border=false
valueattrs=(size=8pt weight = bold)
across=3 location=inside valign=top ;
endlayout;
endgraph;
end;
run;
proc template;
define style styles.mypatterns;
parent=styles.listing;
style GraphData1 from GraphData1 / fillpattern="R1" ;
style GraphData2 from GraphData2 / fillpattern="X1" ;
style GraphData3 from GraphData3 / fillpattern="E" ;
style GraphData4 from GraphData4 / fillpattern="R1" ;
style GraphData5 from GraphData5 / fillpattern="X1" ;
style GraphData6 from GraphData6 / fillpattern="E" ;
style GraphData7 from GraphData7 / fillpattern="R1" ;
style GraphData8 from GraphData8 / fillpattern="X1" ;
style GraphData9 from GraphData9/ fillpattern="E" ;
end;
run;
options orientation=landscape;
ods rtf file="boxplot_grouped.rtf" style=mypatterns;
ods graphics / reset width=8.5in height=5.5in border=off;
proc sgrender data=Dummy_cars_final template=boxplot_template;
run;
ods rtf close; Thank you.
... View more
01-09-2025
12:05 AM
Thank you Ksharp and Tom. Both given the same answers which worked for me. I don't know How I can accept both as solutions. So I selected first one. Sorry Tom🙏
... View more
01-09-2025
12:02 AM
I am comparing the table calculated values done by someone else, variable lengths are not important to compare. I was interested in actual values present in data. when I see so many variables with length differences, it kind of annoying ( I am aware sas presents it for a reason). In this case variable lengths are not important to compare.
... View more
01-08-2025
09:06 PM
I am using the follwing proc compare. But I am seeing the difference of Variable length in Result viewer, can we avoid with any option or statements. I tried this. proc compare base=have comp=want listall ; informat _all_; format _all_; attrib _all_ label=' '; run;
... View more
01-07-2025
04:32 PM
You are genius. Thanks. saved lot of time , I was still searching in internet for that like two days..
... View more
01-06-2025
11:21 PM
Hello Community, I recently started learning SAS, completed my certification, But never exposed to the Graphs before. I got little familar with SGPLOT/ SGPANEL. I am looking to learn proc template. I googled alot and looked on the SAS website I did not got much luck. My professor said, try this website. I am new here , forgive for my mistakes. My questions is How to display the counts inside the Graph? How to display '0' when there is no count? My case make 'custom' is zero count. I have the following Graph, I want to display the counts Inside the graph for each make. I see on SAS website to use the Inner margin and axistable options When I tried I am getting Errors. Can you please help how I can achieve this using Proc template. I am not sure how this website work. if I posted in wrong place please forgive me and guide me to right place. Thank you. Reference Code for inner margin :https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatgraph/p0v5nj3waz75w4n1s2y70echq6im.htm#p08pr1slkds374n14ysbxx1lr3uq data cars;
set sashelp.cars;
where origin = 'USA' and make in ('Saturn' 'Jeep' 'Mercury');
output;
run;
data xx;
make = 'custom';
origin = 'USA';
Run;
data cars1;
set cars xx;
run;
proc freq data = cars;
table make/out = freq;
run;
proc template;
define statgraph boxplot;
begingraph;
entrytitle "City Mileage for Vehicle Types";
layout overlay /
xaxisopts=(offsetmin=0.1 offsetmax=0.1);
boxplot y=mpg_city x=make /
datalabel=make spread=true;
/* Wrong in my code what to enter?*/
innermargin / align=bottom opaque=true backgroundcolor=cxf5f5f5;
axistable x= @@@ value=@@@ /
stat=Sum display=(label)
headerlabel="Counts"
headerlabelattrs=GraphLabelText
valueattrs=(size=9pt weight=bold)
;
endinnermargin;
endlayout;
endgraph;
end;
run;
proc sgrender data=cars1 template=boxplot;
label type="Vehicle Type";
run;
... View more