Recent Activity
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
13
I am writing my thesis and wanted to make a linear regression model, but unfortunately by data is not normally distributed. The assumptions of the linear regression model are the normal distribution of residuals and the constant variance of residuals, which are not satisfied in my case. My supervisor told me that: "You could create a regression model. As long as you don't start discussing the significance of the parameters, the model can be used for descriptive purposes." Is it really true? How can I describe a model like this for example:
grade = - 4.7 + 0.4*(math_exam_score)+0.1*(sex)
if the variables might not even be relevant (can I even say how big the effect was? for example if math exam score is one point higher then the grade was 0.4 higher?)? Also the R square is quite low (on some models 7%, some have like 35% so it isn't even that good at describing the grade..)
Also if I were to create that model, I have some conflicting exams (for example english exam score that can be either taken as a native or there is a simpler exam for those that are learning it as a second language). So there are very few (if any) that took both of these exams (native and second). Therefor, I can't really put both of these in the model, I would have to make two different ones. But since the same case is with a math exam (one is simpler, one is harder) and a extra exam (that only a few people took), it would in the end take 8 models (1. simpler math & native english & sex, 2. harder math & native english & sex, 1. simpler math & english as a second language & sex, .... , simpler math & native english & sex & extra exam). Seems pointless....
Any ideas? Thank you 🙂
... View more

0
7
I want to plot from a proc plm based on a stored dataset output from proc glimmix procedure.
here is my code:
proc glimmix data= insomnia Method=ml noclprint ;
class newid T;
model insomnia = year_1_cvd_time_center cvd_onset cvd_onset*year_1_cvd_time_center
year_1_cvd_time_square cvd_onset*year_1_cvd_time_square is_high_education_y0 is_female age_at_year0
is_high_education_y0*year_1_cvd_time_center is_female*year_1_cvd_time_center age_at_year0*year_1_cvd_time_center/solution notest cl ddfm=bw dist=binary;
random intercept year_1_cvd_time_center year_1_cvd_time_square /subject= newid type=vc;
store out = model_be_cvd_onset;
run;
data disonsetScoreData;
do year_1_cvd_time_center = -6 to 6 by 1;
do cvd_onset = 0 to 1;
year_1_cvd_time_square = (year_1_cvd_time_center ) * (year_1_cvd_time_center);
back_timescale_disonset = year_1_cvd_time_center - 6 ;
age_at_year0 = 56;
is_female = 1;
is_high_education_y0 = 0;
output;
end;
end;
run;
/*for drawing the graph*/
proc plm restore = model_be_cvd_onset;
score data=disonsetScoreData out= be_af_disonset_graph
pred=Predicted lclm=Lower uclm=Upper;
run;
However, above proc plm does not output the probability.
I know below code could output probability for each timepoint, but how could I get it for CVD_onset = 0 and CVD_onset = 1.
ods output fitplot = effectPlotRawData;
proc plm source= insomnia;
effectplot fit(x=year_1_cvd_time_center );
run;
That says, I want to draw two lines using proc plm.
Thanks in advance.
... View more

0
2
I want to know some details about monotone regression multiple imputation. According to the Example provided in SAS Support Document, we can use the DETAILS option and the parameters estimated from the observed data are displayed. We can see that the parameters estimated with observed data using PROC MI are 0.98587(Length1) and -0.04249(Intercept). My understanding is that this result is based only on the observed data, similar to the results we usually obtain from linear regression. Therefore, I use PROC GENMOD to do linear regression, specifying a normal distribution and an identity link function as follows. proc genmod data=fish1;
model Length2 = Length1 / dist=normal link=identity;
run; I find the results from PROC GENMOD are 1.0880 ( for Length1 ) and 0.1348 (for Intercept), which are different from the estimation for observed data in PROC MI mentioned before. For the sake of convenience, I paste the raw data that I use. data Fish1;
title 'Fish Measurement Data';
input Length1 Length2 Length3 @@;
datalines;
23.2 25.4 30.0 24.0 26.3 31.2 23.9 26.5 31.1
26.3 29.0 33.5 26.5 29.0 . 26.8 29.7 34.7
26.8 . . 27.6 30.0 35.0 27.6 30.0 35.1
28.5 30.7 36.2 28.4 31.0 36.2 28.7 . .
29.1 31.5 . 29.5 32.0 37.3 29.4 32.0 37.2
29.4 32.0 37.2 30.4 33.0 38.3 30.4 33.0 38.5
30.9 33.5 38.6 31.0 33.5 38.7 31.3 34.0 39.5
31.4 34.0 39.2 31.5 34.5 . 31.8 35.0 40.6
31.9 35.0 40.5 31.8 35.0 40.9 32.0 35.0 40.6
32.7 36.0 41.5 32.8 36.0 41.6 33.5 37.0 42.6
35.0 38.5 44.1 35.0 38.5 44.0 36.2 39.5 45.3
37.4 41.0 45.9 38.0 41.0 46.5
;
run;
... View more

0
4
Hello, My team and I are trying to execute the sasdm.rexx - console, but once we enter the command, we are always getting the EDC5253S with exit code 255 We have tried to edit .profile file under the user ISHELL and eve we point to different java still same error. Anything that we should try or can do to fix this?
... View more

0
0
Unanswered topics
These topics from the past 30 days have no replies. Can you help?
Subject | Likes | Author | Latest Post |
---|---|---|---|
0 | |||
0 | |||
0 | |||
0 | |||
0 | |||
0 | |||
0 | |||
0 | |||
0 | |||
0 |