SAS中文论坛

 找回密码
 立即注册

扫一扫,访问微社区

查看: 1157|回复: 0
打印 上一主题 下一主题

A new way to draw maps in SAS

[复制链接]

49

主题

76

帖子

1462

积分

管理员

Rank: 9Rank: 9Rank: 9

积分
1462
楼主
 楼主| 发表于 2011-12-7 10:38:11 | 只看该作者

A new way to draw maps in SAS

From Dapangmao's blog on sas-analysis

<div class="separator" style="clear: both; text-align: center;"><a href="http://4.bp.blogspot.com/-DtsQ6-J3WpQ/Tt7OngohQSI/AAAAAAAAA3o/JkKHGJus0oA/s1600/SGPlot.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://4.bp.blogspot.com/-DtsQ6-J3WpQ/Tt7OngohQSI/AAAAAAAAA3o/JkKHGJus0oA/s400/SGPlot.png" width="400" /></a></div><br />
SAS’s ODS Graphics technology brought the concept of layer into data visualization. We can use those SG procedures to do many tricks. Previously in SAS, a map has to be drawn from <a href="http://support.sas.com/documentation/cdl/en/graphref/63022/HTML/default/viewer.htm#gmap-proc-statement.htm">its GMAP procedure</a>. Now we can simply use 3-4 lines of codes to sketch some maps by the scatter statement in PROC SGPLOT, such as North America or Asia. <br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-SsPeeDVc2jE/Tt7OylMr1PI/AAAAAAAAA30/8sLbHEsEb3U/s1600/SGPlot1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://2.bp.blogspot.com/-SsPeeDVc2jE/Tt7OylMr1PI/AAAAAAAAA30/8sLbHEsEb3U/s400/SGPlot1.png" width="400" /></a></div><br />
<pre style="background-color: #ebebeb; border: 1px dashed rgb(153, 153, 153); color: #000001; font-size: 14px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>ods html style = money;
proc sgplot data = maps.namerica noautolegend;
scatter x = x y = y / group = id  markerattrs=(size=1);
xaxis grid label = ' '; yaxis grid label = ' ';
run;
proc sgplot data = maps.china ;
scatter x = x y = y /markerattrs=(size=2);
xaxis grid label = ' '; yaxis grid label = ' ';
run;
</code></pre><div class="separator" style="clear: both; text-align: center;"><a href="http://2.bp.blogspot.com/-8vEy8sQRK5U/Tt7O4v0_qnI/AAAAAAAAA4A/uCWtFNMkqHA/s1600/SGPlot2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="300" src="http://2.bp.blogspot.com/-8vEy8sQRK5U/Tt7O4v0_qnI/AAAAAAAAA4A/uCWtFNMkqHA/s400/SGPlot2.png" width="400" /></a></div><br />
<div class="separator" style="clear: both; text-align: center;"><a href="http://1.bp.blogspot.com/-H-phdsYI4lg/Tt7O9WLD7vI/AAAAAAAAA4M/u7530ZSl3M0/s1600/SGPlot4.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="400" src="http://1.bp.blogspot.com/-H-phdsYI4lg/Tt7O9WLD7vI/AAAAAAAAA4M/u7530ZSl3M0/s400/SGPlot4.png" width="400" /></a></div><br />
<br />
We can apply it to single countries, like China or India. For India, the aspect has to be modified a little. It can be aslo done by PROC SGSCATTER. My friend Xiangxiang has a great<a href="http://www.google.com/url?sa=t&amp;rct=j&amp;q=&amp;esrc=s&amp;source=web&amp;cd=1&amp;ved=0CB8QFjAA&amp;url=http%3A%2F%2Fsupport.sas.com%2Fresources%2Fpapers%2Fproceedings10%2F057-2010.pdf&amp;ei=Es_eTtzBE6r4sQL7pZimBw&amp;usg=AFQjCNHFRyrPhn6oUXgmugPWm2tmAPYXpw&amp;sig2=2jAblgXHy_o6CwvH3HsEvg"> tutorial</a> for this procedure. <br />
<pre style="background-color: #ebebeb; border: 1px dashed rgb(153, 153, 153); color: #000001; font-size: 14px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"><code>
ods html style = harvest;
proc sgplot data = maps.asia noautolegend;
scatter x = x y = y / group = id  markerattrs=(size=1);
xaxis grid label = ' '; yaxis grid label = ' ';
run;

ods html style = htmlbluecml;
ods graphics on / width=6in height = 6in;
proc sgplot data = maps.india;
scatter x = x y = y /markerattrs=(size=2);
xaxis grid label = ' '; yaxis grid label = ' ';
run;
ods graphics  / reset;
</code></pre>Thanks to SAS’s ODS group, those SG procedures always give me limitless fun<div class="blogger-post-footer"><img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/3256159328630041416-4317076571577001891?l=www.sasanalysis.com' alt='' /></div><img src="http://feeds.feedburner.com/~r/SasAnalysis/~4/VX7SW81ORU0" height="1" width="1"/>
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|SAS中文论坛  

GMT+8, 2025-9-6 21:38 , Processed in 0.069116 second(s), 20 queries .

Powered by Discuz! X3.2

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表