BookmarkSubscribeRSS Feed
PaalNavestad
Pyrite | Level 9

Hi I'm working with SGPanel and heatmapparam. I get some unexcpected behaviour and challenges in controlling axis. Below is what I get. Data and code at the bottom.

 

Org_prob.PNG
The y or row axis behaves strangely. Trying to recreate I created some dummy data
Data forSGpanel_problem;
	call streaminit(1234);
	do date='01feb2010'd to '31dec2017'd by 280;
		Panel='pan1';
		x=1;
		number=rand('POISSON',3);
		output;
		Panel='pan1';
		x=2;
		number=rand('POISSON',3.5);
		output;
		
		panel='pan2';
		x=1;
		number=rand('POISSON',4);
		output;
		panel='pan2';
		x=2;
		number=rand('POISSON',4.5);
		output;
	end;
	format date monyy5.;
run;
data forsgpanel_problem;
	set forsgpanel_problem;
	date_txt=put(date,monyy5.);
run;

ods graphics on  / width=900 px height=600 px imagemap;

proc sgpanel data=forSGpanel_problem;	
	where date ge '01jan2015'd;
	panelby panel;
	heatmapparm x=x y=date colorresponse=number/outline;
	text x=x y=date text=date_txt;
*	rowaxis interval=month;
run;
Although the gist of the data being reasonable similar I get a really different graph. I do not get the breaks in the y axis and the boxes are placed in a seemingly erronous fashion.
Does anybody have an idea why this behaves like this. In the work I'm doing at the moment I have to solve this using text on the Y-axis that works well. However I foresee having to use this with more numeric cases further down the line and would like to know the reason and how it can be overcome using the right settings on the axis if possible?
DummyData.PNG
data test;
  infile datalines dsd truncover;
  input ch_ind:32. AIgeo_adp_cl:32. PCT_ROW:32. mnth_txt:$14. mnth:MONYY5. mnth_plt:$12.;
datalines4;
-1,1,8.9009525761,JUL15,JUL15,L08-09-JUL15
0,1,5.1881971043,JUL15,JUL15,L08-09-JUL15
1,1,0.4662548083,JUL15,JUL15,L08-09-JUL15
-1,2,63.341186111,JUL15,JUL15,L08-09-JUL15
0,2,8.4343303867,JUL15,JUL15,L08-09-JUL15
1,2,0,JUL15,JUL15,L08-09-JUL15
-1,3,8.1122605756,JUL15,JUL15,L08-09-JUL15
0,3,3.5235709713,JUL15,JUL15,L08-09-JUL15
1,3,0.3030656254,JUL15,JUL15,L08-09-JUL15
-1,4,0,JUL15,JUL15,L08-09-JUL15
0,4,0,JUL15,JUL15,L08-09-JUL15
1,4,98.379764541,JUL15,JUL15,L08-09-JUL15
-1,5,5.5925432756,JUL15,JUL15,L08-09-JUL15
0,5,5.1320356288,JUL15,JUL15,L08-09-JUL15
1,5,0.3613474764,JUL15,JUL15,L08-09-JUL15
-1,6,11.973778552,JUL15,JUL15,L08-09-JUL15
0,6,5.6161475474,JUL15,JUL15,L08-09-JUL15
1,6,0.4429420678,JUL15,JUL15,L08-09-JUL15
-1,7,2.0383078972,JUL15,JUL15,L08-09-JUL15
0,7,8.5657482393,JUL15,JUL15,L08-09-JUL15
1,7,0.0466254808,JUL15,JUL15,L08-09-JUL15
-1,8,0.040971013,JUL15,JUL15,L08-09-JUL15
0,8,63.539970122,JUL15,JUL15,L08-09-JUL15
1,8,0,JUL15,JUL15,L08-09-JUL15
-1,1,4.186728072,APR16,APR16,L09-10-APR16
0,1,5.252798498,APR16,APR16,L09-10-APR16
1,1,3.519727505,APR16,APR16,L09-10-APR16
-1,2,5.23341009,APR16,APR16,L09-10-APR16
0,2,13.141080639,APR16,APR16,L09-10-APR16
1,2,12.035197275,APR16,APR16,L09-10-APR16
-1,3,41.720745238,APR16,APR16,L09-10-APR16
0,3,1.9783791422,APR16,APR16,L09-10-APR16
1,3,0.0567697985,APR16,APR16,L09-10-APR16
-1,4,5.1287418882,APR16,APR16,L09-10-APR16
0,4,8.0336324454,APR16,APR16,L09-10-APR16
1,4,6.6988362191,APR16,APR16,L09-10-APR16
-1,5,9.8806782499,APR16,APR16,L09-10-APR16
0,5,4.6441440987,APR16,APR16,L09-10-APR16
1,5,2.0720976441,APR16,APR16,L09-10-APR16
-1,6,3.5377852208,APR16,APR16,L09-10-APR16
0,6,5.9411936894,APR16,APR16,L09-10-APR16
1,6,4.3145046835,APR16,APR16,L09-10-APR16
-1,7,0.0628009211,APR16,APR16,L09-10-APR16
0,7,5.4365051327,APR16,APR16,L09-10-APR16
1,7,69.25915413,APR16,APR16,L09-10-APR16
-1,8,30.24911032,APR16,APR16,L09-10-APR16
0,8,55.572266354,APR16,APR16,L09-10-APR16
1,8,2.0437127448,APR16,APR16,L09-10-APR16
-1,1,5.5873925501,OCT16,OCT16,L10-11-OCT16
0,1,5.2175836996,OCT16,OCT16,L10-11-OCT16
1,1,3.2598920863,OCT16,OCT16,L10-11-OCT16
-1,2,4.7564469914,OCT16,OCT16,L10-11-OCT16
0,2,13.536753392,OCT16,OCT16,L10-11-OCT16
1,2,1.506294964,OCT16,OCT16,L10-11-OCT16
-1,3,0,OCT16,OCT16,L10-11-OCT16
0,3,0,OCT16,OCT16,L10-11-OCT16
1,3,88.916366906,OCT16,OCT16,L10-11-OCT16
-1,4,22.836676218,OCT16,OCT16,L10-11-OCT16
0,4,7.6031096316,OCT16,OCT16,L10-11-OCT16
1,4,1.8660071942,OCT16,OCT16,L10-11-OCT16
-1,5,4.3266475645,OCT16,OCT16,L10-11-OCT16
0,5,4.9993462935,OCT16,OCT16,L10-11-OCT16
1,5,0.5395683453,OCT16,OCT16,L10-11-OCT16
-1,6,5.5873925501,OCT16,OCT16,L10-11-OCT16
0,6,5.9145354158,OCT16,OCT16,L10-11-OCT16
1,6,2.9451438849,OCT16,OCT16,L10-11-OCT16
-1,7,53.782234957,OCT16,OCT16,L10-11-OCT16
0,7,5.9789003651,OCT16,OCT16,L10-11-OCT16
1,7,0.1573741007,OCT16,OCT16,L10-11-OCT16
-1,8,3.1232091691,OCT16,OCT16,L10-11-OCT16
0,8,56.749771203,OCT16,OCT16,L10-11-OCT16
1,8,0.809352518,OCT16,OCT16,L10-11-OCT16
-1,1,5.4568527919,MAY17,MAY17,L11-12-MAY17
0,1,5.0484297036,MAY17,MAY17,L11-12-MAY17
1,1,8.544869503,MAY17,MAY17,L11-12-MAY17
-1,2,5.7106598985,MAY17,MAY17,L11-12-MAY17
0,2,12.231679875,MAY17,MAY17,L11-12-MAY17
1,2,37.754737218,MAY17,MAY17,L11-12-MAY17
-1,3,22.165820643,MAY17,MAY17,L11-12-MAY17
0,3,3.3411603561,MAY17,MAY17,L11-12-MAY17
1,3,0.572041473,MAY17,MAY17,L11-12-MAY17
-1,4,37.182741117,MAY17,MAY17,L11-12-MAY17
0,4,7.3652284512,MAY17,MAY17,L11-12-MAY17
1,4,1.1798355381,MAY17,MAY17,L11-12-MAY17
-1,5,4.1878172589,MAY17,MAY17,L11-12-MAY17
0,5,4.531846199,MAY17,MAY17,L11-12-MAY17
1,5,14.837325706,MAY17,MAY17,L11-12-MAY17
-1,6,5.0338409475,MAY17,MAY17,L11-12-MAY17
0,6,5.6403483025,MAY17,MAY17,L11-12-MAY17
1,6,11.548087236,MAY17,MAY17,L11-12-MAY17
-1,7,8.6717428088,MAY17,MAY17,L11-12-MAY17
0,7,7.0100772919,MAY17,MAY17,L11-12-MAY17
1,7,16.410439757,MAY17,MAY17,L11-12-MAY17
-1,8,11.590524535,MAY17,MAY17,L11-12-MAY17
0,8,54.831229821,MAY17,MAY17,L11-12-MAY17
1,8,9.1526635681,MAY17,MAY17,L11-12-MAY17
-1,1,0,OCT17,OCT17,L12-13-OCT17
0,1,5.1485037859,OCT17,OCT17,L12-13-OCT17
1,1,0,OCT17,OCT17,L12-13-OCT17
-1,2,0,OCT17,OCT17,L12-13-OCT17
0,2,12.752977992,OCT17,OCT17,L12-13-OCT17
1,2,0,OCT17,OCT17,L12-13-OCT17
-1,3,0,OCT17,OCT17,L12-13-OCT17
0,3,3.6834899554,OCT17,OCT17,L12-13-OCT17
1,3,0,OCT17,OCT17,L12-13-OCT17
-1,4,0,OCT17,OCT17,L12-13-OCT17
0,4,7.8605955053,OCT17,OCT17,L12-13-OCT17
1,4,0,OCT17,OCT17,L12-13-OCT17
-1,5,0,OCT17,OCT17,L12-13-OCT17
0,5,4.7927280178,OCT17,OCT17,L12-13-OCT17
1,5,0,OCT17,OCT17,L12-13-OCT17
-1,6,0,OCT17,OCT17,L12-13-OCT17
0,6,5.780890557,OCT17,OCT17,L12-13-OCT17
1,6,0,OCT17,OCT17,L12-13-OCT17
-1,7,0,OCT17,OCT17,L12-13-OCT17
0,7,7.2915405463,OCT17,OCT17,L12-13-OCT17
1,7,0,OCT17,OCT17,L12-13-OCT17
-1,8,0,OCT17,OCT17,L12-13-OCT17
0,8,52.68927364,OCT17,OCT17,L12-13-OCT17
1,8,0,OCT17,OCT17,L12-13-OCT17
;;;;
run;

proc sgpanel data=test;
	format mnth monyy5.;
	panelby ch_ind / columns=3;
	heatmapparm x=aigeo_adp_cl y=mnth colorresponse=pct_row/ outline ;
run;
2 REPLIES 2
ballardw
Super User

First a comment on using:

data forsgpanel_problem;
set forsgpanel_problem;
date_txt=put(date,monyy5.);
run;

 

Habitual use of that structure will eventually cause a problem with hard to trace down data errors. In your example the variable could be added as

do date='01feb2010'd to '31dec2017'd by 280;
      date_txt=put(date,monyy5.);

Second it is not obvious which graph you want, which goes with which code, exactly what is wrong,and you say "The y or row axis behaves strangely." without describing what "strangely" may mean.

 

If the issue is that gaps appear in the values that is a function of your MNTH values, they are not evenly spaced: Jul15, Apr16, Oct16, May17 and Oct17 which becomes a bit more obvious if you add

   rowaxis values=('01JUL15'd '01Apr16'd '01Oct16'd '01May17'd '01Oct17'd);

to the second code.

 

PaalNavestad
Pyrite | Level 9

Hi ballardw, sry for not making myself clear. The challenge is that to similar datasets give different results, none of them being right. 

 

Controllable solution is to use a character variable. As you can see there is one on the second code snippet. using this give a nice result. However you have to either add a variable that sorts right, For dates using yyyymm or a prefix and monyy5. format. In the current case I'm working this is acceptable. But future cases it might not be. Thanks for your interest.

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 647 views
  • 0 likes
  • 2 in conversation