- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi all,
I am trying to get ideas for generating a trend graph by year and a few other variables (4 exactly) by a categorical variable (3 categories).
the year value represents crime per thousand. The building, traffic, space, and quality variables are all survey values (higher score is better)
Any cool ideas are appreciated. Thanks
data have;
infile datalines dlm=',';
input Area :$5. Year_2020 Year_2021 Year_2022 Building Traffic Space Quality;
datalines;
A,64,114,105,12.8,15,3.6,16.6
B,7,12,14,13.9,14.7,14.8,17.5
C,1,6,4,16.9,18.5,17,19.6
;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
With SAS any sort of trend data will go much better with one observation per date (daily, monthly, yearly what ever).
An approach to a basic series plot based on the time value. The data step creates one observation for the apparent category variable and time point. You didn't mention what value any of those "year" variables represented. A variable name and label to make more sense in the graph display would be a very good.
Without any description of what any of Building Traffic Space Quality mean and how they would relate to a "trend" I ignore them. Some sort of meaning would be needed.
data toplot; set have; array y(2020:2022) year_2020 Year_2021 Year_2022 ; do year = 2020 to 2022; Yearvalue = y[year]; output; end; keep area year yearvalue; run; proc sgplot data=toplot; series x=year y=yearvalue/ group=area; run;
If I knew that the year value represented something such as "price in $1,000s" a label for such could appear on the year helping someone understand what is displayed.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for this, the year value represents crime per thousand. The building, traffic, space, and quality variables are all survey values (higher score is better)
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
It looks like you need Mixed Model to take into account of other independent variables (Building Traffic Space Quality) for trend analysis .
Thus, better post it at Statistical Forum:
https://communities.sas.com/t5/Statistical-Procedures/bd-p/statistical_procedures
data have;
infile datalines dlm=',';
input Area :$5. Year_2020 Year_2021 Year_2022 Building Traffic Space Quality;
datalines;
A,64,114,105,12.8,15,3.6,16.6
B,7,12,14,13.9,14.7,14.8,17.5
C,1,6,4,16.9,18.5,17,19.6
;
data want;
set have;
array x{*} Year_2020 Year_2021 Year_2022;
do i=1 to dim(x);
y=x{i};time=input(scan(vname(x{i}),-1,'_'),best.);output;
end;
drop i Year_:;
run;
proc glimmix data=want;
class area time;
model y=Building Traffic Space Quality time/solution dist=poisson;
random time/residual subject=area type=ar(1);
store out=MixedModel;
run;
proc plm restore=MixedModel;
effectplot interaction (x=time )/clm connect;;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Is there a 3D plot that i can perhaps use with say 2 continuous variables (Year_2022, quality) and categorical variable Area? This would be helpful
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
define statgraph layoutoverlay3d;
begingraph;
entrytitle "Density Plot of Height and Weight";
layout overlay3d / tilt=10 rotate=54
walldisplay=none cube=false;
surfaceplotparm x=height y=weight z=density /
surfacecolorgradient=density;
endlayout;
endgraph;
end;
run;
proc sgrender data=sashelp.gridded template=layoutoverlay3d;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
proc template;
define statgraph layoutoverlay3d;
begingraph;
entrytitle "Density Plot of crime and quality score";
layout overlay3d / tilt=10 rotate=54
walldisplay=none cube=false;
surfaceplotparm x=Year_2020 y=quality z=Area /
surfacecolorgradient=Area;
endlayout;
endgraph;
end;
run;
proc sgrender data=have template=layoutoverlay3d;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Try this one.
And you need more data to plot 3D graph.
data have;
infile datalines dlm=',';
input Area :$5. Year_2020 Year_2021 Year_2022 Building Traffic Space Quality;
datalines;
A,64,114,105,12.8,15,3.6,16.6
B,7,12,14,13.9,14.7,14.8,17.5
C,1,6,4,16.9,18.5,17,19.6
;
proc format;
invalue ifmt
'A'=1
'B'=2
'C'=3;
value fmt
1='A'
2='B'
3='C';
run;
data have;
set have;
_area=input(area,ifmt.);
format _area fmt.;
run;
proc kde data=have;
bivar _Area Quality/ plots=all;
freq Year_2022;
run;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
data have;
infile datalines dlm=',';
input Area :$5. Year_2020 Year_2021 Year_2022 Building Traffic Space Quality;
datalines;
A,64,114,105,12.8,15,3.6,16.6
B,7,12,14,13.9,14.7,14.8,17.5
C,1,6,4,16.9,18.5,17,19.6
;
proc format;
invalue ifmt
'A'=1
'B'=2
'C'=3;
value fmt
1='A'
2='B'
3='C';
run;
data have;
set have;
_area=input(area,ifmt.);
format _area fmt.;
run;
proc kde data=have;
bivar _Area Quality/out=want;
freq Year_2022;
run;
proc template;
define statgraph layoutoverlay3d;
begingraph;
entrytitle "Density Plot of Height and Weight";
layout overlay3d / tilt=10 rotate=54
walldisplay=none cube=false;
surfaceplotparm x=value1 y=value2 z=density /
surfacecolorgradient=density;
endlayout;
endgraph;
end;
run;
proc sgrender data=want template=layoutoverlay3d;
format value1 fmt.;
label value1='Area' value2='Year_2022';
run;