BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
PaigeMiller
Diamond | Level 26

I have a process which produces is described by two values (variable names VALUE1 and VALUE2), and an output variable Y. VALUE1 is always greater than or equal to VALUE2. I would like to produce a heatmap of VALUE1 and VALUE2 based on the values of Y, which because of this restriction, will produce a lower triangular plot, with the upper left triangle blank. 

 

proc sgplot data=temp2;
    heatmap x=value1 y=value2/colormodel=(green yellow red) colorresponse=y showybins
        xbinstart=400 xbinsize=20 ybinsize=20 ybinstart=400;
run;

PaigeMiller_0-1723641065777.png

 

 

Note that the plot does NOT have bins with binsize 20 for value2 on the Y-axis, even though I specifically asked for ybinsize=20. It seems to have bins of size 35. The x-axis does have bins of size 20, which is what I asked for. How to fix this?

 

Data is below (it's kind of long)

 

data WORK.TEMP2;
  infile datalines dsd truncover;
  input value1:F4. value2:F4. y:32.;
  format value1 F4. value2 F4.;
datalines4;
420,400,0.605140682
440,420,0.996768081
460,420,0.4042534743
460,440,0.9471383762
460,460,1.1169751621
480,420,0.2178766906
480,440,0.5606897799
480,460,1.0073036206
480,480,0.7763154056
500,440,0.4553268
500,460,0.741822483
500,480,0.5674189203
500,500,0.5201927576
520,400,1.4602307034
520,440,1.0692899207
520,460,0.6303615208
520,480,0.6049262914
520,500,0.5647691518
520,520,0.5794153417
540,420,0.6463655542
540,440,1.1439050719
540,460,0.7464762036
540,480,0.6048583631
540,500,0.6105364259
540,520,0.6763947277
540,540,0.8170202941
560,440,0.6818541734
560,460,0.5450794599
560,480,0.584097944
560,500,0.6378951082
560,520,0.8048750711
560,540,0.7016555563
560,560,0.7193345689
580,400,1.1596742065
580,420,0.5045887427
580,440,0.430374778
580,460,0.9818743162
580,480,0.6610817536
580,500,0.741852897
580,520,0.7862914353
580,540,0.7393147526
580,560,0.7307963183
580,580,0.7346891431
600,440,0.6746657856
600,460,0.7085897167
600,480,0.6795907016
600,500,0.7126477551
600,520,0.7762505235
600,540,0.7405873734
600,560,0.7119010908
600,580,0.7484395198
600,600,0.7615376622
620,420,0.6238374915
620,440,0.6831680649
620,460,0.6566369599
620,480,0.6519311109
620,500,0.817026954
620,520,0.6949710613
620,540,0.8095672097
620,560,0.7197859921
620,580,0.7327374456
620,600,0.7514244263
620,620,0.784130861
640,400,0.4506078147
640,420,0.5928912466
640,440,0.6435703637
640,460,0.7312076916
640,480,0.8855427692
640,500,0.5960763249
640,520,0.7510737571
640,540,0.7277326191
640,560,0.7013287525
640,580,0.7075087204
640,600,0.7164446165
640,620,0.7374995977
640,640,0.6661786503
660,400,0.6054225989
660,420,0.7770604301
660,440,0.549533613
660,460,0.9919775857
660,480,0.8106216153
660,500,0.6658642881
660,520,0.6511273332
660,540,0.7805980628
660,560,0.7387987764
660,580,0.7268443243
660,600,0.7961082211
660,620,0.6519417766
660,640,0.621630771
660,660,0.6947733219
680,400,0.693392439
680,420,0.8218544043
680,440,0.5994847918
680,460,0.5202433413
680,480,0.6882644008
680,500,0.8165877845
680,520,0.6553030068
680,540,0.736658847
680,560,0.7077427785
680,580,0.7442280453
680,600,0.9153345397
680,620,0.8266723392
680,640,0.7775235241
680,660,0.7236169698
680,680,0.9695681712
700,400,0.4870017647
700,420,0.4539498674
700,440,0.6023998569
700,460,0.6944019317
700,480,0.7731689571
700,500,0.7224267394
700,520,0.691340494
700,540,0.706909818
700,560,0.7366218819
700,580,0.7706142814
700,600,0.9205160276
700,620,0.7431480652
700,640,0.6889014899
700,660,0.8635480179
700,680,0.6903003
700,700,1.00182182
720,400,0.5648077364
720,420,0.5357855712
720,440,0.7747481615
720,460,0.880397038
720,480,0.7521956163
720,500,0.730783861
720,520,0.6591612958
720,540,0.7483504514
720,560,0.7370781275
720,580,0.755790995
720,600,0.7699257819
720,620,0.7796433885
720,640,0.7890577213
720,660,0.8377646261
720,680,0.7851040663
720,700,0.8002649402
720,720,1.0556603665
740,385,0.605140682
740,420,0.4471206926
740,440,0.7248665677
740,460,0.7309507753
740,480,0.7573244358
740,500,0.773739536
740,520,0.6725828474
740,540,0.7735448198
740,560,0.8076411402
740,580,0.804006939
740,600,0.9923356398
740,620,0.723620971
740,640,1.0252848674
740,660,0.7496306812
740,680,0.8590765139
740,700,0.8949354003
740,720,0.9623258509
740,740,1.1852798623
760,400,0.504382142
760,420,0.459023597
760,440,0.6050693545
760,460,0.6565849145
760,480,0.720146268
760,500,0.7563586924
760,520,0.7912334319
760,540,0.763694738
760,560,0.864351685
760,580,0.7791022004
760,600,0.9080961358
760,620,0.7136809901
760,640,0.880411191
760,660,0.8279387923
760,680,0.922887984
760,700,1.0352803622
760,720,1.2263468342
760,740,1.1892877837
760,760,1.5485361645
780,400,0.4044760865
780,420,0.7541273937
780,440,0.7941854448
780,460,0.6953042948
780,480,0.6993349123
780,500,0.8342320232
780,520,0.7174545574
780,540,0.5460453837
780,560,0.8351387138
780,580,0.7441407064
780,600,0.9101953119
780,620,0.8246383825
780,640,0.8812992841
780,660,1.1207389772
780,680,0.8687235224
780,700,1.1076929343
780,720,0.8099459259
780,740,1.2805345421
780,760,1.2303036502
780,780,1.2967949543
800,400,0.6443817676
800,420,0.7086930863
800,440,0.7974331195
800,460,0.7545068701
800,480,0.6337517214
800,500,0.7587073315
800,520,0.6624429998
800,540,0.878866318
800,560,0.7307667771
800,580,0.8388188514
800,600,0.9624215786
800,620,1.1540339145
800,640,0.9146618484
800,660,1.0092363017
800,680,0.9302337637
800,700,0.7338350322
800,720,0.8402777147
800,740,1.264939936
800,760,1.0415098278
800,780,1.2986079169
800,800,1.1206807891
820,400,1.3380401993
820,420,0.7520904518
820,440,0.7543108526
820,460,0.6908947025
820,480,0.7559737606
820,500,0.7450463397
820,520,0.8129723057
820,540,0.79721281
820,560,0.885147276
820,580,0.8240372823
820,600,1.0394952136
820,620,0.6130903858
820,640,1.1675907878
820,660,0.7237804292
820,680,0.5834556179
820,700,1.0225484365
820,720,1.1587056835
820,740,1.0770484109
820,760,1.1072318497
820,780,1.55863315
820,800,1.3287040733
820,820,1.5213726252
840,420,0.2820966005
840,440,0.5765775679
840,460,0.5979218094
840,480,0.7337672925
840,500,0.7142175627
840,520,0.693310539
840,540,0.7569727966
840,560,0.9068089273
840,580,0.7476188882
840,600,0.8945392213
840,620,0.9756927074
840,640,0.4588492485
840,660,1.1684844713
840,680,0.9090417718
840,700,0.5640382241
840,720,1.1138519795
840,740,1.5331246201
840,760,1.4378473916
840,780,1.7630600645
840,800,1.3214352059
840,820,1.1539558667
840,840,1.3934397187
860,420,0.1916648731
860,440,0.8122223114
860,460,0.6313031166
860,480,0.8989546953
860,500,0.7009727196
860,520,0.7749905209
860,540,0.6147296211
860,560,0.8049105026
860,580,1.1921439984
860,600,0.9738621761
860,620,1.4505546129
860,640,1.0920554221
860,660,0.9642754492
860,680,0.5826203676
860,700,1.8113507993
860,720,1.0309106252
860,740,2.2045753726
860,760,1.136041708
860,780,1.2375122086
860,800,1.2324999809
860,820,1.3562622842
860,840,1.4716145558
860,860,1.6538227743
880,440,0.8479691863
880,460,0.605140682
880,480,1.279342697
880,500,0.6724241281
880,520,0.5618041628
880,540,0.9170420899
880,560,0.7850630241
880,580,0.809664395
880,600,0.726939769
880,620,1.1702879978
880,640,0.2288717582
880,660,1.1095659896
880,680,0.529106383
880,700,1.0253520878
880,720,1.0774653527
880,740,1.4398013622
880,760,0.9990801425
880,780,1.0136014482
880,800,1.7196524793
880,820,1.5560571129
880,840,1.3141010339
880,860,1.4324784951
880,880,1.1794076508
900,780,0
900,800,2.3050049743
900,820,3.0007991074
900,840,4.4805858991
900,860,3.0748560383
900,880,1.1440756772
;;;;

 

--
Paige Miller
1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

@PaigeMiller wrote:

Both value1 and value2 are, essentially, discrete. Everything is a multiple of 20. The xbinsize=20 works as expected, but ybinsize=20 does not. Mystifying.

 

@DanH_sas: do you have any suggestions?


I think I found the culprit in the data, not a multiple of 20:

 

720,700,0.8002649402
720,720,1.0556603665
740,385,0.605140682
740,420,0.4471206926
740,440,0.7248665677
740,460,0.7309507753

Change that 385 to 400 and things look a bit more like what you expect.

 

View solution in original post

4 REPLIES 4
ballardw
Super User

I think you are running into one of those internal algorithms and assignment rules. Your data is almost discrete as far as the actual ranges of values of the x and y variables. The values are all multiples of 20 but the range is such that, depending on how end/midpoints are used, requesting 20 bins means the average interval size should be 24 or 25. I'm not sure if there is a way to make only a couple of cells two values "wide" with the rest only one value.

This feels a lot like some of the fights I used to have with GCHART and MIDPOINT setting.

 

Maybe if your Value2 variables showed some variety so that intervals weren't almost pre-binned.

 

I tried Heatmapparm without controls on the bins as an alternate.

PaigeMiller
Diamond | Level 26

Both value1 and value2 are, essentially, discrete. Everything is a multiple of 20. The xbinsize=20 works as expected, but ybinsize=20 does not. Mystifying.

 

@DanH_sas: do you have any suggestions?

--
Paige Miller
ballardw
Super User

@PaigeMiller wrote:

Both value1 and value2 are, essentially, discrete. Everything is a multiple of 20. The xbinsize=20 works as expected, but ybinsize=20 does not. Mystifying.

 

@DanH_sas: do you have any suggestions?


I think I found the culprit in the data, not a multiple of 20:

 

720,700,0.8002649402
720,720,1.0556603665
740,385,0.605140682
740,420,0.4471206926
740,440,0.7248665677
740,460,0.7309507753

Change that 385 to 400 and things look a bit more like what you expect.

 

PaigeMiller
Diamond | Level 26

Thanks!

 

That works, but now I have to figure out how I got an unexpected 385 in the data, different problem.

--
Paige Miller

Ready to join fellow brilliant minds for the SAS Hackathon?

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!
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
  • 4 replies
  • 353 views
  • 3 likes
  • 2 in conversation