proc means data=sashelp.bweight N mean median; var m_wtgain weight; run; proc sgplot data=sashelp.bweight; label m_wtgain="Mother's Weight Gain (Centered)" weight="Baby's Birth Weight"; scatter x=m_wtgain y=weight / transparency=0.9 markerattrs=(symbol=CircleFilled); xaxis values = (-35 to 75 by 10) grid; yaxis values = (0 to 7000 by 1000) grid reverse; run; proc iml; use sashelp.bweight; read all var {m_wtgain weight} into Z; close; start bin2D(u, cutX, cutY); bX = bin(u[,1], cutX); /* bins in X direction: 1,2,...,kx */ bY = bin(u[,2], cutY); /* bins in Y direction: 1,2,...,ky */ bin = bX + (ncol(cutX)-1)*(bY-1); /* bins 1,2,...,kx*ky */ return(bin); finish; cutX = do(-35, 75, 10); cutY = do(0, 7000, 1000); b = bin2D(Z, cutX, cutY); /* bin numbers 1-77 */ call tabulate(binNumber, Freq, b); /* count in each bin */ Count = j(ncol(cutY)-1, ncol(cutX)-1, 0); /* allocate matrix */ Count[binNumber] = Freq; /* fill nonzero counts */ print Count[c=('bX1':'bX11') r=('bY1':'bY7')]; start ExpandGrid( x, y ); /* Return ordered pairs on a uniform grid of points */ Nx = nrow(x); Ny = nrow(y); x = repeat(x, Ny); y = shape( repeat(y, 1, Nx), 0, 1 ); return ( x || y ); finish; centerX = cutX[1:(ncol(cutX)-1)] + (cutX[2]-cutX[1])/2; centerY = cutY[1:(ncol(cutY)-1)] + (cutY[2]-cutY[1])/2; grid = ExpandGrid(centerX, centerY); c = grid || colvec(Count); create Counts from c[colname={x y count}]; append from c; close; quit; data all; set sashelp.bweight counts; run; proc sgplot data=All noautolegend; label m_wtgain="Mother's Weight Gain (Centered)" weight="Baby's Birth Weight"; scatter x=m_wtgain y=weight / transparency=0.95 markerattrs=(symbol=CircleFilled); scatter x=x y=y / markerchar=Count markercharattrs=(size=10 weight=bold); xaxis values = (-35 to 75 by 10) grid offsetmin=0 offsetmax=0; yaxis values = (0 to 7000 by 1000) grid reverse offsetmin=0 offsetmax=0; run;