Recent Activity
Good morning everyone, I'm using SAS Visual Analytics and unfortunately, I can't figure out how to perform a certain operation. Let me describe the situation in general terms: I have a report with two sections: Section 1 and Section 2. Section 1 contains two graphs, Graph 1 and Graph 2, while Section 2 contains a crosstab. All objects are based on the same data source. The two graphs differ only in the assigned Category field (in one case it's A, in the other it's B). Graph 1 filters Graph 2 through an action, and Graph 2 contains a link to the crosstab. In view mode, when I follow the link, the crosstab only receives the selection made on Graph 2, but not the one made on Graph 1 (even though Graph 1 correctly filtered Graph 2). In edit mode, the filter from Graph 1 to Graph 2 doesn't work (an error appears: "Unable to find a column referenced by the query") — however, if I double-click on the bar that appears below the error message, I'm correctly redirected to the desired section with all filters applied, including the selection from Graph 1. If I add Category A as a hidden data element in Graph 2, everything works correctly, but the initial display of Graph 2 changes — and I'd prefer to keep it unchanged. How can I fix this? I have another report that appears to be identical, where everything seems to work without needing hidden elements — but perhaps I’ve missed some detail that allows it to function correctly.
... View more

0
2
Dear SAS Community,
I was hoping to label each category in the bars with the respective percentage, but instead I am getting these numbers. According to the freq table, for the season=2024 the percentage for Hass should be 95% for PeelColor=4 so I wonder what '152' means (green color last column on the right). I would greatly appreciate your help!
This is the code I am using :
title "100 Stacked Bar Chart Ordered by Percentages"; proc sgpanel data=one ; where Variety in('BL516', 'Hass'); panelby Season / columns=4 one panel; vbar Variety / response=PeelColor group=PeelColor grouporder=data groupdisplay=stack seglabel ; colaxis discreteorder=data; rowaxis grid values=(0 to 100 by 10) label="Percentage of PeelColor category"; run;
Frequency
Percent
Row Pct
Col Pct
Table of Variety by PeelColor
Variety
PeelColor
3
4
Total
Hass
2
5.00
5.00
100.00
38
95.00
95.00
100.00
40
100.00
Total
2
5.00
38
95.00
40
100.00
... View more

0
3
I want to identify whether a particular custom function is being used, and if so, determine which rule set/code files/custom functions are using it.
In the case of a Rule set, I can easily do this by clicking on the "View Used By Report" , which lists all objects that use a specific rule set. However, this functionality doesn’t seem to be available for custom functions.
SAS Version: Stable 2024.09
... View more

0
0
I received the following code from a researcher written by her previous programmer. SAS 9.4 /***** ESTIMATING AND PLOTTING K-M curves for HTN ******/ ods graphics on; *ods trace on; ods output SurvivalPlot=sp2 HomTests=pval1;; *Logrank test for composite outcome-KM; proc lifetest data=tab2 plots =SURVIVAL (nocensor test atrisk(atrisktick maxlen=13 outside)=0 50 100 150 200 250); time ptime*event_hbp(0); strata sdbetweenter / order=internal; *Yaxis values=(0.75 to 1.00 by 0.05); *Xaxis label = 'Months of Follow-up'; *title 'Logrank test for coping and all events'; run; quit; data _null_; set pval1(where=(lowcase(test) eq "log-rank")); call symputx("LRPV",put(ProbChiSq,6.4),"G"); run; ods select all; title "Kaplan-Meier Estimates for Hypertension"; title2 height=0.8 "With Number of Subjects at Risk (cause-specific)"; proc sgplot data=sp2 ; step x=time y=survival / group=stratum name='s' lineattrs=(pattern=LongDashShortDash color=yellow); keylegend 's' / location=inside title="Coping variability levels"; Xaxis label="Time from baseline (Months)" labelattrs=(weight=bold); Yaxis label="Survival Percentage" labelattrs=(weight=bold) values=(0.65 to 1.00 by 0.05); inset "Log-Rank p = &LRPV." / position=top border; xaxistable atrisk / x=tatrisk class=stratum /*colorgroup=stratum*/ location=outside; scatter x=time y=censored / markerattrs=(color=black symbol=Plus size=1) name='c'; scatter x=time y=censored / markerattrs=(symbol=Circle size=1) group=stratum; run; I have been able to modify it to satisfy all desired changes with the exception of two. 1. Change all the colors to black or grayscale 2. Instead of color being the identifying characteristic for each Kaplan-Meier curve , use "line styles" such as dotted line, dashed line, dot-dash-dot line, and solid line. I have been some headway using the lineattrs and pattern options, however every lines gets the same treatment and I need to distinguish them with separate treatments. Any help is greatly appreciated. Thank you -Scott
... View more

0
2
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

0
38
Unanswered topics
These topics from the past 30 days have no replies. Can you help?