stata和sas命令对比(3)

2019-03-21 19:22

compute incorrect standard errors. Create a local macro variable ver: %let ver = 7; version = &ver.; Technically, SAS macro variables begin with an ampersand ( & ) and end with a period ( . ). It's good practice to end your macro variables with a period. local ver = 7 gen version = `ver' Notice that to evaluate the local macro variable ver a left quote ( `&nsp;) is used and then a right quote ( '&nsp;). The left quote is located on your keyboard next to the ( ! 1&nsp;) key. list in 1/10 if stores < 20 // the order of if and in does not matter: list if stores < 20 in 1/10 Both will first subset the data to the first 10 observations and then attempt to subset the data based on the condition \if stores < 20\So, a hack way of doing the same in Stata is to use the sum() function. Since sum() creates a running sum, you have to repeat the condition outside the sum() to subset the data to that condition to list the first 10 observations. The sum() function adds up the true conditions because true conditions evaluate to 1 (one) and false evaluate to 0 (zero). list if sum((stores < 20)) <= 10 & stores < 20 So you have to repeat the condition to subset the dataset to just those observations before starting the running sum. If the condition is long you could mess up typing it twice so put it in a local macro variable: local cond stores < 20 list if sum((`cond')) <= 10 & `cond' This is what the Stata command ifwins does. There is no built-in Stata command to do this, but the contract command can be used like so: preserve contract region product stores , /// freq(frequency) /// percent(percentage) /// cfreq(cumulative_freq) /// cpercent(cumulative_pct) list restore Print a subset of observations when a condition is true just to see examples (not all situations) where the condition exists in your data: /** WHERE subsets the data * * before OBS subsets the data */ proc print data= sashelp.shoes (where=(stores < 20) obs = 10); run; The above code lists the first 10 observations where (stores < 20). Get a frequency count for each combination of a set of multiple categorical variables: ** example of a 3-way table **; proc freq data= sashelp.shoes; tables region * product * stores / list; run;

来源:李琦

| 分享(378) | 浏览(1125)

源地址: http://blog.renren.com/GetEntry.do?id=725558273&owner=240755041


stata和sas命令对比(3).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:设备设施报修、急修工作规范

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: