Hi there!
I'd like to ask 2 questions about the logarithm axis graph.
And, I'd like to show my code as well. But please excuse me that I put the original libname and excel data in the code.
Data Test;
Input COL1 COL2 COL3 COL4 COL5 COL6 COL7 COL8 hour;
Cards;
0 0 0 0 0 1123 90515 21879 1
4 24 14 27 220 1123 92276 21887 2
105 36 21 39 100203 1124 97904 21976 4
176 36 21 39 218485 1124 99477 22021 5
;
Run;
Proc Transpose
data = Test out=Test2(drop = _NAME_ drop = _LABEL_ rename=(Col1=Signs))
name = Petition;
by hour;
var COL1-COL8;
Run;
proc sgplot data=pilot.pilot5;
label Signs="Signs" Petition="Petition";
series x=n y=Signs / group=Petition lineattrs=(color=blue pattern=solid);
yaxis label="Signs" type=log logbase=10 logstyle=logexpand values = (100 500 10000 100000 200000);
run;
1. Thanks to Rick, I managed to know about logarithm scale in my graph, but it has an zero number or negative value issue.
This just popped on the log :
NOTE: The log axis cannot support zero or negative values for the axis from plot data or due to default or assigned
BASELINEINTERCEPT value. The axis type will be changed to LINEAR
How can I ease the message and set the logarithm sacle?
2. I transposed the data according to the blog following:https://blogs.sas.com/content/iml/2015/02/25/plotting-multiple-series-transforming-data-from-wide-to...)
(And it was Rick again! I didn't know until this time. Thanks Rick again.)
The question is, Can I choose some COL values which have more than 10,000, 100,000 value in the latest hour?
In the data above, COL5 should be chosen as more than 100,000, and COL7 and COL8 should be chosen as more than 10,000.
After that, I want to draw different color of series graph for them.
(Please note that the original data have about 30000 COLs, and 70 hours now. and later... it would be about 70000 COLs and 720 hours) (If there is a better way to draw series graph with those data, please give me a hint!)
Thank you for the advice, and helps!
I wish I can get you a coffee whoever helps me...
> How can I ease the message and set the logarithm?
Because the LOG function is not defined at 0, you cannot mathematically perform the task that you are requesting. Your options are
1) Set values that are 0 to missing. That will cause those data points to be skipped in the graph
2) Set values that are 0 to 1. On a graph whose vertical axis goes to 100,000, no one will be able to tell the difference between a small count and a zero count.
Regarding your second question, I got an error when I tried to run the sample data that you provided. However, the general question about how to color lines in a spaghetti plot is addressed (with examples) in the article "Create spaghetti plots in SAS." The main idea is to associate a categorical variable with each series and use the GROUPLC= option to assign colors. For example, if you create a variable in the data set called SIZE which is constant for each series which has the values, 10, 100, 1000, 10000, and 100000, then you can add GROUPLC=SIZE to the SERIES statement to color the lines.
Regarding "is there a better way," the answer is probably yes. I don't think you are going to glean much insight from plotting 30,000 series at 70 time points. I suggest that you describe what you are trying to ACCOMPLISH. Are you trying to identify series that are outliers? Are you monitoring the values and want to find processes that are "out of control." Are you trying to visualize trends? You can answer these questions without plotting 30,000 series.
Good luck.
For your last question, Check ranges= option.
yaxis ranges=
Thank you for the advice Ksharp!
But unfortunately, I'm beginner of SAS so... it will take some times to check what you said.
I'm looking on SAS HELP for options you mentioned now.
Thank you again!
Hi @Ksharp , I am having trouble in generating semi log graph using the proc template. Can you please identify what I am doing wrong in my code. It only generating linear graph. Thank you very much.
proc means data = sashelp.class nway;
class age sex;
var weight;
output out= class_mean n=n mean= _MEAN std= sd ;
run;
data mean1;
set class_mean;
lower = _MEAN - sd;
upper = _MEAN - sd;
run;
ods path(prepend) work.templat(update);
proc template;
define statgraph series;
begingraph/ BORDER=False datasymbols=( circle Asterisk) ;
layout lattice / rowdatarange=data columndatarange=data rowgutter=10 columngutter=10;
layout overlay / xaxisopts=( label=('Age') tickvalueattrs=(family='Courier New' size=8 ) labelattrs=(family='Courier New' size=8 )
linearopts=( viewmin=10 viewmax=20 tickvaluesequence=( start=0.0 end=20 increment=1)))
yaxisopts=( label=('weight)') type=log labelattrs=(family='Courier New' size=8 ) tickvalueattrs=(family='Courier New' size=8 )
linearopts=( viewmin=40 viewmax=160.0 tickvaluesequence=( start=0.0 end=160.0 increment=20.0)));
seriesplot x=age y= _MEAN / group=sex name='series' display=(markers) connectorder=xaxis ;
scatterplot x=age y= _MEAN / yerrorupper = upper yerrorlower = lower group=trtan name='scatter';
discretelegend 'series' / opaque=false border=true halign=right valign=top displayclipped=true across=2 order=rowmajor location=inside titleattrs=(family='Courier New' size=8 );
endlayout;
endlayout;
endgraph;
end;
run;
ods graphics on/ width=9 in height=4.6 in ;
options orientation = landscape errors = 2 missing = ' ' nofmterr ls = 175 validvarname = upcase nofmterr nobyline
noquotelenmax ;
ods escapechar = '^';
ods results on;
ods listing close;
ods rtf file = "&location.\chk.rtf"
style = rtf nogtitle nogfootnote;
proc sgrender data=mean1 template=series;
run;
ods rtf close;
ods listing close;
> How can I ease the message and set the logarithm?
Because the LOG function is not defined at 0, you cannot mathematically perform the task that you are requesting. Your options are
1) Set values that are 0 to missing. That will cause those data points to be skipped in the graph
2) Set values that are 0 to 1. On a graph whose vertical axis goes to 100,000, no one will be able to tell the difference between a small count and a zero count.
Regarding your second question, I got an error when I tried to run the sample data that you provided. However, the general question about how to color lines in a spaghetti plot is addressed (with examples) in the article "Create spaghetti plots in SAS." The main idea is to associate a categorical variable with each series and use the GROUPLC= option to assign colors. For example, if you create a variable in the data set called SIZE which is constant for each series which has the values, 10, 100, 1000, 10000, and 100000, then you can add GROUPLC=SIZE to the SERIES statement to color the lines.
Regarding "is there a better way," the answer is probably yes. I don't think you are going to glean much insight from plotting 30,000 series at 70 time points. I suggest that you describe what you are trying to ACCOMPLISH. Are you trying to identify series that are outliers? Are you monitoring the values and want to find processes that are "out of control." Are you trying to visualize trends? You can answer these questions without plotting 30,000 series.
Good luck.
Thank you again Rick. And sorry for the error. I tried to ask question without attaching excel file so that anyone can read it simple way. But it seems I had done some mistake in there.
For your advices,
I substituted all 0 values into 1.
And what I am trying to accomplish is... visualizing trends while I can stress some contrasts gap of values.
Actually I'm following precedent study, and just trying to track what they have done. But you got a point. In the study, it only shows the basic trends. But it was quite... impressive. So that's why I'm trying to do this.
But it seems it's going to be very heavy if I collect data for 30 days. So I'm thinking about simplifying it.
I'll attach the sgplot I drew. Actually It's um... messy right now, but I want to show you how it went.
And for the solutions you mentioned, (especially Spaghetti plots! that's what i wanted) I'm working on it!
Thank you for the help again Rick.
I really appreciate.
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: