统计软件SAS教程SAS练习

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

libnamedy'd:\dzwj';datady.by_student;procprintdata=dy.c9501;bysex;/*分类*/run;procprint;run;(女性一栏无法输出,并且满足条件的男性没有输出来)libnamedy'd:\dzwj';datady.sum_bkmoney;procprintdata=dy.bkmoneynoobs;sumamount;/*sum函数求和*/run;libnamedy'd:\dzwj';procsortdata=dy.c9501;byname;procsortdata=dy.bkmoney;byname;datady.c9501bk;mergedy.c9501dy.bkmoney;/*merge横向合并*/byname;run;procsortdata=dy.c9501bk;bysex;procprintdata=dy.c9501bk;bysex;sumamount;run;libnamedy'd:\dzwj';datady.table_c9501bk;proctabulatedata=dy.c9501bk;/*tabulate分类汇总*/classsex;varamount;tablesex,amount;run;procprint;run;(出现乱码)libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;tablesex,(mathchinese)*(meanstd);/*求变量的均值*/run;procprint;run;libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;tableallsex,(mathchinese)*(meanstd);/*求所有的变量的均值*/run;procprint;run;libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;table(sexall)*(NPCTN);/*频数分布*/run;procprint;run;libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;table(sexall)*math*(meanstd);/*指定变量math的均值和方差*/run;procprint;run;libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;table(sexall),(mathchinese)*(meanstd);/*统计量加标签*/keylabelmean='平均值'std='标准差'all='总计';labelsex='性别'math='数学'chinese='语文';run;procprint;run;libnamedy'd:\dzwj';datady.meanstd_c9501;proctabulatedata=dy.c9501bk;classsex;varmathchinese;table(sexall='总计'),(mathchinese)*(mean='平均值'std='标准差');/*统计量加标签,标签加在其中*/labelsex='性别'math='数学'chinese='语文';run;procprint;run;(结果如上图所示)libnamedy'd:\dzwj';datady.by_sex;procsortdata=dy.c9501;bysex;run;procprint;run;libnamedy'd:\dzwj';datady.by_sex;procsortdata=dy.c9501;bysexdescendingmath;run;procprint;run;(矩阵的转置没有实现,165页)libnamedy'd:\dzwj';datady.means_c9501;procmeansdata=dy.c9501;/*描述性统计*/run;procprint;run;libnamedy'd:\dzwj';datady.freq_c9501;procfreqdata=dy.c9501;/*求频率和累计值*/tablessex;run;procprint;run;第五章多元统计分析主分量分析:LIBNAMEdy'd:\dzwj';DATAdy.TEMPERAT;INPUTCITY$JANUARYJULY;CARDS;MOBILE10.727.6PHOENIX10.732.9LITTLEROCK4.227.4SACRAMENTO7.324.0DENVER-1.222.8HARTFORD-4.022.6WILMINGTON0.024.3WASHINGTONDC2.025.9JACKSONVILLE12.627.2MOBILE10.727.6PHOENIX10.732.9LITTLEROCK4.227.4SACRAMENTO7.324.0DENVER-1.222.8HARTFORD-4.022.6WILMINGTON0.024.3WASHINGTONDC2.025.9JACKSONVILLE12.627.2SIOUXFALLS-9.922.9MEMPHIS4.726.4NASHVILLE3.526.4DALLAS7.129.3ELPASO6.427.9HOUSTON11.228.5SALTLAKECITY-2.224.8BURLINGTON-8.421.0NORFOLK4.725.7RICHMOND3.125.5SPOKANE-3.720.9CHARLESTON,WV1.423.9MILWAUKEE-7.021.1CHEYENNE-3.020.6;PROCPRINCOMPCOVOUT=PRIN;/*主分量也就是主成分的意思,out保护原始数据和主分量得分的数据集从协方差阵出发计算主分量*/VARJULYJANUARY;RUN;libnamedy'd:\dzwj';datady.crime;title'各州每十万人的犯罪率';INPUTSTATE$MURDERRAPEROBBERYASSAULTBURGLARYLARCENYAUTO;CARDS;ALABAMA14.225.296.8278.31135.51881.9280.7ALASKA10.851.696.8284.01331.73369.8753.3ARIZONA9.534.2138.2312.32346.14467.4439.5ARKANSAS8.827.683.2203.4972.61862.1183.4CALIFORNIA11.549.4287.0358.02139.43499.8663.5COLORADO6.342.0170.7292.91935.23903.2477.1CONNECTICUT4.216.8129.5131.81346.02620.7593.2DELAWARE6.024.9157.0194.21682.63678.4467.0FLORIDA10.239.6187.9449.11859.93840.5351.4GEORGIA11.731.1140.5256.51351.12170.2297.9HAWAII7.225.5128.064.11911.53920.4489.4IDAHO5.519.439.6172.51050.82599.6237.6ILLINOIS9.921.8211.3209.01085.02828.5528.6INDIANA7.426.5123.2153.51086.22498.7377.4IOWA2.310.641.289.8812.52685.1219.9KANSAS6.622.0100.7180.51270.42739.3244.3KENTUCKY10.119.181.1123.3872.21662.1245.4LOUISIANA15.530.9142.9335.51165.52469.9337.7MAINE2.413.538.7170.01253.12350.7246.9MARYLAND8.034.8292.1358.91400.03177.7428.5MASSACHUSETTS3.120.8169.1231.61532.22311.31140.1MICHIGAN9.338.9261.9274.61522.73159.0545.5MINNESOTA2.719.585.985.81134.72559.3343.1MISSISSIPPI14.319.665.7189.1915.61239.9144.4MISSOURI9.628.3189.0233.51318.32424.2378.4MONTANA5.416.739.2156.8804.92773.2309.2NEBRASKA3.918.164.7112.7760.02316.1249.1NEVADA15.849.1323.1355.02453.14212.6559.2NEWHAMPSHIRE3.210.723.276.01041.72343.9293.4NEWJERSEY5.621.0180.4185.11435.82774.5511.5NEWMEXICO8.839.1109.6343.41418.73008.6259.5NEWYORK10.729.4472.6319.11728.02782.0745.8NORTHCAROLINA10.617.061.3318.31154.12037.8192.1NORTHDAKOTA0.99.013.343.8446.11843.0144.7OHIO7.827.3190.5181.11216.02696.8400.4OKLAHOMA8.629.273.8205.01288.22228.1326.8OREGON4.939.9124.1286.91636.43506.1388.9PENNSYLVANIA5.619.0130.3128.0877.51624.1333.2RHODEISLAND3.610.586.5201.01489.52844.1791.4SOUTHCAROLINA11.933.0105.9485.31613.62342.4245.1SOUTHDAKOTA2.013.517.9155.7570.51704.4147.5TENNESSEE10.129.7145.8203.91259.71776.5314.0TEXAS13.333.8152.4208.21603.12988.7397.6UTAH3.520.368.8147.31171.63004.6334.5VERMONT1.415.930.8101.21348.22201.0265.2VIRGINIA9.023.392.1165.7986.22521.2226.7WASHINGTON4.339.6106.2224.81605.63386.9360.3WESTVIRGINIA6.013.242.290.9597.41341.7163.3WISCONSIN2.812.952.263.7846.92614.2220.7WYOMING5.421.939.7173.9811.62772.2282.0;PROCPRINCOMPCOVOUT=CRIMCOMP;RUN;PROCSORT;BYPRIN1;PROCPRINT;IDSTATE;VARPRIN1PRIN2MURDERRAPEROBBERYASSAULTBUR

1 / 17
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功