How to draw histogram chart for time series in SAS using proc gchart - graph

I need to draw a histogram to make comparison between two series. I have the following code, but the proc gchart is not working.
data test;
input date $ irate ppi savings income cpi;
datalines;
JUN1990 8.43 114.3 2.412 83.83 129.9
JUL1990 8.76 114.5 2.473 68.147 130.4
AUG1990 8.94 116.5 4.594 84.205 131.6
SEP1990 8.85 118.4 3.893 84.016 132.7
OCT1990 8.67 120.8 3.816 52.269 133.5
NOV1990 8.51 120.1 5.35 97.008 133.8
DEC1990 8.13 118.7 4.253 81.292 133.8
JAN1991 7.98 119 3.872 57.779 134.6
FEB1991 7.92 117.2 4.249 62.566 134.8
MAR1991 8.09 116.2 6.117 77.929 135
APR1991 8.31 116 3.69 92.044 135.2
MAY1991 8.22 116.5 3.798 59.509 135.6
JUN1991 8.02 116.3 1.812 59.549 136
JUL1991 7.68 116 2.951 49.197 136.2
;
run;
proc reg data=test;
model irate = ppi savings income cpi /p;
output out=b p=py;
run;
quit;
axis1 minor=none major=(h=1) label=none
order=(0 to 120000 by 10000) ;
axis2 major=(height=1) value=none
label=none offset=(5, 5)pct ;
axis3 label=none nobrackets ;
axis4 minor=none major=(h=1) label=none
order=(0 to 120000 by 60000) ;
axis5 minor=none major=(h=1) label=none
order=(0 to 120000 by 20000) ;
axis6 minor=none major=(h=1) label=none
order=(0 to 119000 by 17000) ;
pattern1 c=ligr ;
pattern2 c=gray ;
proc gchart data=test ;
title 'Too Many' ;
vbar group /
sumvar=value2 group=date
noframe nolegend
subgroup=group
raxis=axis1 maxis=axis2 gaxis=axis3
width=12 space=0 gspace=4
coutline=same ;
format date monname3. value2 comma10.0;
run ;
title 'Odd Tick Mark Intervals' ;
vbar group /
sumvar=value2 group=date
subgroup=group
noframe nolegend
raxis=axis6 maxis=axis2 gaxis=axis3
width=12 space=0 gspace=4
coutline=same ;
format date monname3. value2 comma10.0;
run ;
quit ;
I want to make the final graph like this:
Can someone help me to change the proc gchart code or you can use your own method to do this?

As someone else mentioned - your test data does not contain the variables GROUP and VALUE2 that you are trying to call in your PROC GCHART. I think to match your example, you will need to separate the date into month and year in order to chart year in side-by side bars. Below is some GCHART code that creates a histogram similar to your example. You will need to change the response variable to what you are trying to chart.
Hope this helps.
*** CREATE MONTH AND YEAR AS SEPARATE VARIABLES ***;
data test_fix;
set test;
*** FIRST CONVERT DATE FROM CHARACTER STRING TO NUMERIC SAS DATE VARIABLE ***;
date_sas=input(date, ANYDTDTE.);
*** USE SAS DATE VARIABLE TO GET MONTH AND YEAR AS NUMERIC VARIABLES ***;
month=month(date_sas);
year=year(date_sas);
run;
proc print data=test_fix;
format date_sas mmddyy10.;
run;
axis1 label=('MONTH') offset=(5,5);
axis2 label=none value=none;
axis3 label=(a=90 'PPI') ;
pattern1 v=solid color=greyc0; *** LIGHT GREY ***;
pattern2 v=solid color=grey40; *** DARY GREY ***;
proc gchart data=test_fix;
vbar year /
type=sum sumvar=ppi
group=month subgroup=year
discrete
space=0
gaxis=axis1 /* GROUP AXIS (X-AXIS) - MONTH */
maxis=axis2 /* MID POINT AXIS (X-AXIS) - YEAR */
raxis=axis3 /* RESPONSE AXIS (Y-AXIS) - PPI */
;
run;
quit;

Related

How to plot an antenna pattern in a polar diagram in Octave?

I'm having some problems with polar plot in Octave. In particular I made a script that combine the horizontal and vertical antenna pattern in order to obtain the 3D antenna pattern of the antenna such that the result is a matrix of 360x360 elements. If I plot the matrix by means of surf function I obtain that image but I would like to get an antenna pattern diagram. How I can do that?
EDIT:
theta3D = linspace(0, 2*pi - (2*pi/360), 360);
phi3D = linspace(0, 2*pi - (2*pi/360), 360);
%% from dBm to dB
maxGainVdB = mGVNnA - 30;
maxGainHdB = mGHNnA - 30;
%% from dB to Watt
maxGainVWatt = 10.^(maxGainVdB/10);
maxGainHWatt = 10.^(maxGainHdB/10);
%% normalization
maxGainVWattNorm = maxGainVWatt./max(maxGainVWatt);
maxGainHWattNorm = maxGainHWatt./max(maxGainHWatt);
%% Gv and Gh
Gv = 10*log10(maxGainVWattNorm);
Gh = 10*log10(maxGainHWattNorm);
%% weighting factors
% where "i" is theta and j is phi
for i = 1 : length(phi3D)
for j = 1 : length(theta3D)
w1(i, j) = maxGainVWattNorm(i)*(1 - maxGainHWattNorm(j));
w2(i, j) = maxGainVWattNorm(j)*(1 - maxGainHWattNorm(i));
end
end
%% normalization-related parameter
k = 2; %% As indicated in Chapter 2
%% estimated G
for i = 1 : length(phi3D)
for j = 1 : length(theta3D)
estG(i, j) = ((Gh(i)*w1(i,j) + Gv(j)*w2(i,j))/((w1(i,j)^k + w2(i,j)^k))^(1/k));
end
end
figure
[X, Y] = meshgrid (theta3D, phi3D);
surf(X,Y,estG)
DATA
mGHNnA = [0.0762 0.0976 0.1207 0.146 0.1744 0.2066 0.2428 0.2827 0.3256 0.3705 0.4165 0.4631 0.5107 0.5602 0.6129 0.6704 0.7334 0.8021 0.8754 0.9518 1.0294 1.1067 1.1834 1.2608 1.3419 1.4318 1.5376 1.6653 1.8213 2.011 2.2382 2.5046 2.8096 3.1494 3.5171 3.8976 4.2687 4.6021 4.8717 5.0727 5.201 5.2687 5.2965 5.3066 5.3189 5.3365 5.3865 5.4558 5.5635 5.7028 5.8633 6.0489 6.2538 6.4708 6.6929 6.914 7.1293 7.3344 7.5209 7.6879 7.8455 7.9974 8.1362 8.2677 8.4072 8.547 8.6955 8.8539 9.025 9.21 9.4099 9.6251 9.8558 10.102 10.362 10.636 10.924 11.224 11.536 11.858 12.189 12.528 12.875 13.229 13.59 13.954 14.323 14.696 15.071 15.447 16.203 16.58 17.089 17.593 18.093 18.588 19.077 19.56 20.036 20.506 20.969 21.424 21.861 22.278 22.683 23.081 23.47 23.856 24.235 24.609 24.98 25.344 25.698 26.037 26.347 26.622 26.87 27.09 27.289 27.459 27.601 27.729 27.849 27.962 28.068 28.158 28.244 28.282 28.272 28.233 28.204 28.181 28.182 28.2 28.21 28.203 28.206 28.181 28.185 28.238 28.346 28.526 28.794 29.158 29.616 30.155 30.753 31.375 31.988 32.556 33.032 33.32 33.435 33.452 33.476 33.597 33.831 34.167 34.581 35.047 35.48 35.784 36.026 36.134 35.959 35.742 35.544 35.466 35.575 35.746 35.995 36.162 36.19 36.11 35.912 35.695 35.529 35.417 35.401 35.464 35.467 35.622 35.747 35.773 35.787 35.827 35.802 35.722 35.596 35.544 35.59 35.687 35.784 35.857 35.867 35.804 35.679 35.462 35.131 34.68 34.179 33.68 33.231 32.833 32.532 32.326 32.18 32.035 31.752 31.265 30.628 29.95 29.221 28.526 27.919 27.419 27.03 26.737 26.542 26.415 26.341 26.301 26.269 26.241 26.212 26.179 26.143 26.102 26.051 25.983 25.892 25.795 25.707 25.636 25.584 25.542 25.502 25.464 25.424 25.362 25.269 25.156 25.013 24.827 24.604 24.343 24.042 23.713 23.361 22.998 22.62 22.229 21.827 21.418 21.004 20.587 20.156 19.72 19.278 18.833 18.385 17.934 17.478 17.018 16.555 16.086 15.614 15.138 14.658 14.175 13.689 13.336 12.982 12.629 12.277 11.926 11.577 11.23 10.887 10.549 10.215 9.8873 9.5665 9.2535 8.9474 8.6508 8.3601 8.0783 7.8076 7.5485 7.2995 7.0654 6.8356 6.6223 6.418 6.2237 6.0401 5.8621 5.6946 5.5356 5.384 5.2382 5.0961 4.9558 4.8113 4.6579 4.5018 4.3427 4.182 4.022 3.8609 3.7051 3.5585 3.4213 3.2873 3.1583 3.032 2.9015 2.7555 2.6037 2.4462 2.284 2.1188 1.9533 1.7903 1.6325 1.4827 1.3435 1.209 1.0844 0.9762 0.8832 0.7952 0.7224 0.6616 0.609 0.5607 0.5128 0.4625 0.4103 0.3567 0.3033 0.2521 0.2051 0.164 0.1295 0.1013 0.0786 0.06 0.0442 0.0304 0.0182 0.0083 0.0019 0 0.0035 0.0125 0.0242 0.0388 0.0564]
and
mGVNnA = [ 1.7 1.1099 0.7069 0.4755 0.2901 0.1465 0.0475 0 0.0014 0.0449 0.1292 0.2868 0.4673 0.7364 1.2223 1.9732 3.0173 4.3603 5.9631 7.7179 9.5019 9.832 8.9113 8.2694 8.0057 8.1343 8.6399 9.5171 10.742 12.285 14.065 16.092 18.473 21.416 25.15 27.353 27.395 26.174 23.967 21.86 20.131 18.734 17.599 16.638 15.887 15.369 15.082 15.024 15.211 15.606 16.196 16.958 17.868 18.867 20 20.151 19.842 19.695 19.725 19.787 19.905 20.082 20.265 20.432 20.595 20.789 21.013 21.281 21.623 22.058 22.536 23.101 23.715 24.38 25.113 25.898 26.737 27.595 28.478 29.381 30.284 31.155 31.971 32.721 33.389 33.969 34.473 34.88 35.237 35.563 35.885 36.251 36.805 37.442 38.143 38.785 39.282 39.452 39.252 38.808 38.293 37.764 37.253 36.773 36.34 35.953 35.634 35.368 35.192 35.093 35.087 35.161 35.305 35.638 35.968 36.19 36.22 36.098 35.797 35.382 35.001 34.788 34.768 34.921 35.411 36.172 36.807 36.485 36.261 35.984 35.618 35.165 34.735 34.498 34.647 35.242 36.268 37.584 38.828 39.695 40.087 40.283 40.635 41.382 42.64 43.356 41.606 40.07 39.359 39.185 39.081 38.836 38.624 38.456 38.255 38.206 38.493 39.266 40.491 41.983 43.328 42.563 40.545 38.503 37.071 36.429 36.194 36.104 35.836 35.579 35.481 35.506 35.707 35.994 36.07 36.031 36.033 36.214 36.667 37.435 38.147 38.873 39.727 40.902 42.706 43.934 43.635 43.926 44.379 44.797 45.114 45.558 46.371 47.239 49.24 52.957 57.002 55.602 53.712 53.855 57.666 52.999 48.404 45.794 44.523 44.54 44.979 45.826 47.281 48.725 49.537 49.035 47.911 45.782 43.136 40.9 39.415 38.682 38.471 38.664 39.083 39.55 39.89 39.954 39.921 40.111 40.907 41.583 41.361 41.264 40.952 40.156 39.005 37.776 36.579 35.531 34.625 33.843 33.158 32.54 32.059 31.661 31.352 31.117 30.908 30.74 30.578 30.447 30.306 30.141 29.997 29.704 29.318 28.964 28.61 28.262 27.903 27.512 27.083 26.622 26.123 25.592 25.037 24.464 23.88 23.292 22.702 22.114 21.537 20.976 20.433 19.985 19.564 19.172 18.811 18.484 18.191 17.938 17.728 17.566 17.458 17.411 17.431 17.437 16.937 16.486 16.093 15.757 15.479 15.269 15.133 15.062 15.072 15.144 15.254 15.407 15.568 15.726 15.86 15.971 16.077 16.2 16.408 16.719 17.174 17.79 18.611 19.673 21.051 22.834 24.971 27.442 29.851 27.032 24.994 23.406 21.624 20.012 18.602 17.435 16.433 15.668 15.115 14.729 14.47 14.339 14.383 14.654 15.252 16.216 14.91 13.992 13.353 12.978 12.89 13.16 13.841 14.942 16.463 18.341 20.559 23.437 26.905 27.021 23.385 19.308 16.1 13.668 11.801 10.36 9.2831 8.5509 8.1662 8.1298 8.4381 7.8963 6.1559 4.6964 3.4785 2.4834 ]
I have no idea which kind of polar plots you are expecting, but the below code may help you to make it as an example.
2D polar plot
% polar plot for G vs. phi, when theta = pi
polar(phi3D, estG(:,length(theta3D)/2+1));
hold on;
% polar plot for G vs. theta, when phi = pi
polar(theta3D, estG(length(phi3D)/2+1,:));
legend("G vs. phi #(theta=pi)","G vs. theta #(phi=pi)");
title("2D radiation pattern");
hold off;
- 3D polar plot
[X, Y] = meshgrid (theta3D, phi3D);
surf(X,Y,estG,'LineStyle','none');
xlabel("theta");
ylabel("phi");
zlabel("G");
colormap("jet");
colorbar
The code that you have included does generate an estimate of gain vs theta and phi, however, you are plotting it on rectangular coordinates. if you noticed, in the resultant figure, the x and y axes are ranging from 0 to 2pi.
you created a (theta, phi, magnitude) data set, and need to convert that to an x,y,z data set.
doing a coordinate transformation, similar to:
xconv = estG.*sin(theta3D).*cos(phi3D);
yconv = estG.*sin(theta3D).*sin(phi3D);
zconv = estG.*cos(theta3D);
may give you what you need.
surf(xconv,yconv,zconv,'Edgecolor','none')
produces:
Since I'm not exactly sure what output would be correct from this data, I can't tell if that quite has it. There may be some ordering issues with mesh and surf plot data that i'm not aware of.
I recommend always starting simple. Work with a unit gain omnidirectional antenna, and see if your process above can go from two circle plots to a sphere. then generate more complex patterns.
for reference, here's a decent set of classroom exercises on 3D parametric plots

SAS: Can you save the input table of a SAS generated bar-line chart?

So I am generating a SAS bar-line chart in SAS with a dataset which looks like this:
id date default var1 log_var1 square_var1 ... cubic_var1
1 1 1 5 -3.3 0.9 1.2
1 2 0 15 -9.9 2.7 3.6
2 1 1 10 -6.6 1.8 2.4
...
Note, the transformations are not
log(var1)
but actually the transformation from the regression so
log_var1 = alpha + beta log(var1)
Now I use the following code, generated by the SAS task for bar-line chart:
SYMBOL1
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CI=WHITE
CV = _STYLE_
;
SYMBOL2
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL3
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL4
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL5
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CV = _STYLE_
;
SYMBOL6
INTERPOL=JOIN
HEIGHT=10pt
VALUE=SQUARE
LINE=1
WIDTH=2
CI=WHITE
CV = _STYLE_
;
Legend2
FRAME
;
Legend1
FRAME
;
Axis1
STYLE=1
WIDTH=1
MINOR=NONE
;
Axis2
STYLE=1
WIDTH=1
;
Axis3
STYLE=1
WIDTH=1
MINOR=NONE
;
TITLE;
TITLE1 "Bar-Line Chart";
FOOTNOTE;
FOOTNOTE1 "Generated by the SAS System (&_SASSERVERNAME, &SYSSCPL) on %TRIM(%QSYSFUNC(DATE(), NLDATE20.)) at %TRIM(%SYSFUNC(TIME(), TIMEAMPM12.))";
PROC GBARLINE DATA=WORK.SORTTempTableSorted
;
BAR var1
/
FRAME LEVELS=25
COUTLINE=BLACK
RAXIS=AXIS1
MAXIS=AXIS2
LEGEND=LEGEND2
;
PLOT / SUMVAR=default
TYPE=MEAN
AXIS=AXIS3
LEGEND=LEGEND1
;
PLOT / SUMVAR=lin_var1
TYPE=MEAN
AXIS=AXIS3
;
PLOT / SUMVAR=sigmoid_var1
TYPE=MEAN
AXIS=AXIS3
;
PLOT / SUMVAR=square_var1
TYPE=MEAN
AXIS=AXIS3
;
PLOT / SUMVAR=cubic_var1
TYPE=MEAN
AXIS=AXIS3
;
PLOT / SUMVAR=log_var1
TYPE=MEAN
AXIS=AXIS3
;
/* -------------------------------------------------------------------
End of task code
------------------------------------------------------------------- */
RUN; QUIT;
%_eg_conditional_dropds(WORK.SORTTempTableSorted);
TITLE; FOOTNOTE;
GOPTIONS RESET = SYMBOL;
My question is:
Can I somehow store or save the input to create this histogram?
I.e. a table that contains the mean value for default,
var1, square_var1, cubic_var1 for the 25 equally spaced bins?
The premise of doing this is that all the inputs are on different scales and so I'd like to standardise the inputs and then plot the graphs
Note: I can take the time to code up the binning myself but this would truly be a trick of a lazy programmer!
There is no option on the GBARLINE procedure for outputting the plotting parameters it computes. Your default graphical options probably creates a png image for an html page that is used to present the chart for viewing.
Change the graphics devices to svg and ODS will create html source that contains the drawing instructions for creating the image seen. The instructions will be in the <g> tag. So, if you are truly motivated to be lazy and not hand code the midpoints and axis values, you can write code to parse the html and scrape the computed midpoints and axis ticks from within the <g> tag.
ods html5 file="c:\temp\gbarline.html";
goptions reset=all;
goptions device=svg;
… gbarline …
ods html5 close;
… parse the ODS created c:\temp\gbarline.html …

Plotting a 1D dot plot in SAS

Hello, I would like to plot something that is close to this but
I cannot seem to get it.
I have the data
data table2_1;
input Modified_Mortar Unmodifided_Mortar;
cards;
16.85 16.62
16.40 16.75
17.21 17.37
16.35 17.12
16.52 16.98
17.04 16.87
16.96 17.34
17.15 17.02
16.59 17.08
16.57 17.27
;
run;
And I tried
proc freq data=table2_1;
tables Modified_Mortar / plots=freqplot (type=dotplot);
tables Unmodifided_Mortar / plots=freqplot (type=dotplot);
run;
but it gave me an unnecessarily huge plot which was spaced equally and cannot compare the two distributions as I intended.
I played around a bit with sgplot and this is the closest I could come up with. It's not exact, but with a little fiddling in an image editor you can pretty much get it.
data table2_1;
input Modified_Mortar Unmodifided_Mortar;
retain mod_line 0.75 unmod_line 0;
cards;
16.85 16.62
16.40 16.75
17.21 17.37
16.35 17.12
16.52 16.98
17.04 16.87
16.96 17.34
17.15 17.02
16.59 17.08
16.57 17.27
;
run;
proc sgplot data=table2_1;
label Modified_Mortar = 'Strength (kgf/cm squared)';
scatter x = Modified_Mortar y=mod_line / markerattrs=(symbol=circlefilled color=black size=10);
scatter x = Unmodifided_Mortar y=unmod_line / markerattrs=(symbol=circlefilled color=bib size=10);
refline -0.25 / axis=y lineattrs=(color=bib thickness=2) name='mod' legendlabel='Unmodified' ;
refline 0.5 / axis=y lineattrs=(color=black thickness=2) name='unmod' legendlabel='Modified';
yaxis display=(nolabel) min=-0.25 max=15;
xaxis values=(16.24 to 17.50 by 0.14) min=16.30 max=17.40 valueattrs=(size=12) labelattrs=(size=12);
keylegend 'mod' 'unmod' / location=outside position=bottom valueattrs=(size=12);
run;
Here is a different approach that uses the data in a treatment:response categorical form. A labeled triangle marker is used to show the mean (triangle apex being the balance point)
data have;
treatment = 'Modified '; y=1.13; input response #; output;
treatment = 'Unmodified'; y=0.13; input response; output;
attrib
response label = "Strength (kgf/cm2)"
;
cards;
16.85 16.62
16.40 16.75
17.21 17.37
16.35 17.12
16.52 16.98
17.04 16.87
16.96 17.34
17.15 17.02
16.59 17.08
16.57 17.27
;
run;
proc sql;
create table plot as
select * from have
outer union corresponding
select
treatment,
case treatment
when ('Unmodified') then -0.15
when ('Modified ') then 0.85
else 0
end as y2,
mean(response) as mean format=5.2
from have
group by treatment;
quit;
ods proclabel "Concrete dot plot";
ods graphics / height=220px width=800px;
proc sgplot data=plot description="Response to treatment";
title "Concrete strength response to treatment";
scatter
x=response y=y
/ markerattrs=(symbol=circlefilled color=black size=12px)
;
scatter
x=mean y=y2
/ datalabel=mean
datalabelpos=bottom
markerattrs=(symbol=triangle color=black size=12px)
;
keylegend
/ exclude = ("y" "y2")
;
yaxis
offsetmin = 0.2
values = ( 0 1 2 )
valuesdisplay = ( "Unmodified" "Modified" " " )
display = ( noticks nolabel )
colorbands = odd
;
xaxis
grid
;
refline 0.00 ;
refline 1.00 ;
run;
title;
footnote;

SAS plot SGPLOT

I have 3 columns A, B, C. I tried to do a overlay plot, which shows one line of B and one line of C (A is the x axis). However, when I use the code below, the output looks super ugly. What is a better way to do it? Thank you.
proc plot data=djia;
plot A*B='*'
A*C='o' / overlay box;
title 'Plot of Highs and Lows';
title2 'for the Dow Jones Industrial Average';
run;
http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a002473570.htm
In SGPLOT the plotting statements, by defaults, plot onto the same graphing 'canvas', and thus overlay. The first statements are drawn first, so you can produce any desired 'z-effect' for the overlaying.
Example plotting djia data.
proc sgplot data=djia;
band x=year lower=low upper=high / fillatrrs=(color=vlig);
series x=year y=high / markers;
series x=year y=low / markers;
run;
The SAS knowledge base article http://support.sas.com/kb/51/821.html shows how to band (fill) the region between low and high.
Data for example
* from http://support.sas.com/documentation/cdl/en/proc/61895/HTML/default/viewer.htm#a000075748.htm#a000075747 ;
data djia;
input Year #7 HighDate date7. High #24 LowDate date7. Low;
format highdate lowdate date7.;
datalines;
1954 31DEC54 404.39 11JAN54 279.87
1955 30DEC55 488.40 17JAN55 388.20
1956 06APR56 521.05 23JAN56 462.35
1957 12JUL57 520.77 22OCT57 419.79
1958 31DEC58 583.65 25FEB58 436.89
1959 31DEC59 679.36 09FEB59 574.46
1960 05JAN60 685.47 25OCT60 568.05
1961 13DEC61 734.91 03JAN61 610.25
1962 03JAN62 726.01 26JUN62 535.76
1963 18DEC63 767.21 02JAN63 646.79
1964 18NOV64 891.71 02JAN64 768.08
1965 31DEC65 969.26 28JUN65 840.59
1966 09FEB66 995.15 07OCT66 744.32
1967 25SEP67 943.08 03JAN67 786.41
1968 03DEC68 985.21 21MAR68 825.13
1969 14MAY69 968.85 17DEC69 769.93
1970 29DEC70 842.00 06MAY70 631.16
1971 28APR71 950.82 23NOV71 797.97
1972 11DEC72 1036.27 26JAN72 889.15
1973 11JAN73 1051.70 05DEC73 788.31
1974 13MAR74 891.66 06DEC74 577.60
1975 15JUL75 881.81 02JAN75 632.04
1976 21SEP76 1014.79 02JAN76 858.71
1977 03JAN77 999.75 02NOV77 800.85
1978 08SEP78 907.74 28FEB78 742.12
1979 05OCT79 897.61 07NOV79 796.67
1980 20NOV80 1000.17 21APR80 759.13
1981 27APR81 1024.05 25SEP81 824.01
1982 27DEC82 1070.55 12AUG82 776.92
1983 29NOV83 1287.20 03JAN83 1027.04
1984 06JAN84 1286.64 24JUL84 1086.57
1985 16DEC85 1553.10 04JAN85 1184.96
1986 02DEC86 1955.57 22JAN86 1502.29
1987 25AUG87 2722.42 19OCT87 1738.74
1988 21OCT88 2183.50 20JAN88 1879.14
1989 09OCT89 2791.41 03JAN89 2144.64
1990 16JUL90 2999.75 11OCT90 2365.10
1991 31DEC91 3168.83 09JAN91 2470.30
1992 01JUN92 3413.21 09OCT92 3136.58
1993 29DEC93 3794.33 20JAN93 3241.95
1994 31JAN94 3978.36 04APR94 3593.35
;
In general in SGxxx procs you just add more statements to get more things to appear on the graph. For example you might want to show regression lines for AGE * WEIGHT and AGE * HEIGHT on the same graph.
proc sort data=sashelp.class out=class ;
by age;
run;
proc sgplot data=class;
reg x=age y=weight / legendlabel='Weight';
reg x=age y=height / legendlabel='Height' y2axis;
run;

gnuplot Heatmap with label and score from different columns data

I have created heatmap graphs using gnuplot.
I have data.dat:
avail reli perf
stop 181 20 121 10 34 20
jitter 18 20 17 20 13 20
limp 12 20 5 30 20 20
and gnuplot script:
set term pos eps font 20
unset key
set nocbtics
set cblabel "Score"
set cbtics scale 0
set cbrange [ 0.00000 : 110.00000 ] noreverse nowriteback
set palette defined ( 0.0 "#FFFFFF",\
1 "#FFCCCC",\
20.2 "#FF9999 ",\
30.3 "#FF6666",\
40.4 "#FF3333",\
50.5 "#FF0000",\
60.6 "#CC0000",\
70.7 "#C00000",\
80.8 "#B00000",\
90.9 "#990000",\
100.0 "#A00000")
set title "Faults"
set ylabel "Hardware Faults"
set xlabel "Aspects"
set size 1, 0.5
set output 'c11.eps'
YTICS="`awk 'BEGIN{getline}{printf "%s ",$1}' 'data2.dat'`"
XTICS="`head -1 'data2.dat'`"
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) i-1 )
set for [i=1:words(YTICS)] ytics ( word(YTICS,i) i-1 )
plot "<awk '{$1=\"\"}1' 'data2.dat' | sed '1 d'" matrix w image, '' matrix using 1:2:($3==0 ? " " : sprintf("%.1d",$3)) with labels
#######^ replace the first field with nothing
################################## ^ delete first line
My output is:
Here I have range 1-20,30-39,...,100 or more)
Now I have to 2 values in every axis. e.g stop and avail have(181 and 20). the 181 is the count and 20 is percentages. I want to create graphs which have colors base on percentages and the labels on my graphs from the counts of data.
I have experienced create some graph using for and do some modulo to select the data. But here, I have not idea to create that graphs. Any suggestion for creating this? Thanks!
You can use every to skip columns.
plot ... every 2 only uses every second column, which is what you can use for the labels. For the colors, you must start with the second column (numbered with 1), and you need every 2::1.
Following are the relevant changes only to your script:
set for [i=1:words(XTICS)] xtics ( word(XTICS,i) 2*i-1 )
plot "<awk '{$1=\"\"}1' 'data2.dat' | sed '1 d'" matrix every 2::1 w image, \
'' matrix using ($1+1):2:(sprintf('%d', $3)) every 2 with labels
The result with 4.6.5 is:

Resources