资源描述:
《stata和sas命令对比》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、已有556次阅读2010-5-810:56
2、个人分类:Stata
3、系统分类:科研笔记
4、关键词:SAS,STATASASStataInSASoperatorscanbesymbolsormnemonicequivalentssuchas:&orandFormanysituationsinSASorderdoesn'tmatter:<=canbe:==canbe:=>MostoperatorsarethesameinStataasinSAS,butinStataoperatorsdonothavemn
5、emonicequivalents. Forexample,youhavetousetheampersand( & )andnottheword"and".Thisworks:var_a>=1&var_b<=10wherethisdoesnot:var_a>=1andvar_b<=10ThesearetheoperatorsthataredifferentinStata:SymbolDefinition&and
6、or>=greaterthanorequalto<=lessthanorequalto==equ
7、ality(forequalitytesting)!=doesnotequal!not^powerNote: Symbolshavetobeintheordershown:">="not"=>"./*thisisacomment*/*thisisalsoacomment;/*thisisacomment*/*thisisalsoacomment//thisisacommentaswellTocontinueacommandtothenextline(linecontinuation):///youcanco
8、mmenthereaswellForexample:listidstategenderageincome///raceincomedateRangeofvalues:if1<=var_a<=10or:ifvar_ain(1,2,3,4,5,6,7,8,9,10)oralistofcharactervalues:ifstatein("NC","AZ","TX","NY","MA","CA","NJ")ifvar_a>=1&var_a<=10or:ifinrange(var_a,1,10)or:ifinlist
9、(var_a,1,2,3,4,5,6,7,8,9,10)oralistofstringvalues:ifinlist(state,"NC","AZ","TX","NY","MA","CA","NJ")Statahasalimitof10argumentstoinlist()(whichincludesthestringvariable)whentheargumentsarestrings. Morethanonevariablecanbespecified.Referencingmultiplevariab
10、lesatatime:Saythefollowingvariablesareinadatafileintheordershown:var1var2var3agevar4var5Thenyoucouldcodethemas:var1--var5ToSAS,thismeans"allvariablesthatarepositionallybetweenvar1andvar5,"whichwouldincludethevariableage.Referencingmultiplevariablesatatime:
11、var1-var5ToStata,thismeans"allvariablesthatarepositionallybetweenvar1andvar5." Noticethatthereisonlyonedash( - ).Referencingmultiplevariablesatatime:var1-var5isthesameas:var1var2var3var4var5nomatterthepositionsofthevariablesareintheobservation.Usingacolons
12、electsvariablescontainingthesameprefix:var:couldrepresent:var1var2var10variablevaryingvar_1Referencingmultiplevariablesatatime:var?Thequestionmark( ? )isawildcardthatrepresentsonecharacterinthevariablename. I