Kaz SAS Manual BasicWord格式文档下载.docx

上传人:b****6 文档编号:19436611 上传时间:2023-01-06 格式:DOCX 页数:31 大小:484.85KB
下载 相关 举报
Kaz SAS Manual BasicWord格式文档下载.docx_第1页
第1页 / 共31页
Kaz SAS Manual BasicWord格式文档下载.docx_第2页
第2页 / 共31页
Kaz SAS Manual BasicWord格式文档下载.docx_第3页
第3页 / 共31页
Kaz SAS Manual BasicWord格式文档下载.docx_第4页
第4页 / 共31页
Kaz SAS Manual BasicWord格式文档下载.docx_第5页
第5页 / 共31页
点击查看更多>>
下载资源
资源描述

Kaz SAS Manual BasicWord格式文档下载.docx

《Kaz SAS Manual BasicWord格式文档下载.docx》由会员分享,可在线阅读,更多相关《Kaz SAS Manual BasicWord格式文档下载.docx(31页珍藏版)》请在冰豆网上搜索。

Kaz SAS Manual BasicWord格式文档下载.docx

5.HowdowecreateSASdata?

9

A)CreateaSASdatausingaSASsyntax9

B)CreateSASdataVia.Ms-ExcelSheets10

C)CreateaSASdatasetviaanexternaltextfile11

6.Examplesofdatasteps12

7.Manipulatingvariablesindatasteps13

8.Lotsofmanipulationtechniquestobeusedinadatastep14

9.UsingCharacterFunctionstocreatenewvariables15

10.Application:

HowdowerestrictanalyticalsamplesusingNMISSfunction15

II.Procedures16

11.PROCCONTENTS:

DescriptionofContents16

12.PROCPRINT:

SeeData17

13.PROCSORT:

SortingObservationsbasedonavalueofvariable19

14.PROCMEANS:

GetDescriptiveStatistics(Mean,STD,Min,Max)20

15.PROCFREQ:

GetFrequencies21

16.PROCUNIVARIATE:

Getelaboratestatisticsandaunivariateplot21

17.PROCPLOT:

PlottingTwoVariables21

18.PROCTIMEPLOT:

TimePlot22

19.PROCCORR:

Correlation22

20.PROCREG:

OLSRegression22

21.PROCLOGISTIC:

LogisticRegression23

22.MAKEANASCHIFILE23

III.MoreProcedures24

23.PROCSTANDARD:

StandardizeValues24

24.PROCRANK:

Rankobservations25

25.PROCSQL:

Creatinggroup-levelmeanvariables25

26.PROCIMPORT26

IV.MergingDataSets27

V.MACROs28

27.Mostcommonwayofusingamacro28

28.SimplemacrousingLETstatement28

29.Macrocanbespecifiedfromdata(notdirectlybyyou)28

I.BasicOperations

1.AskquestionstoSASbyemailingsupport@

WhenyouhaveaquestionaboutSAS,youcanemailSASinstitutes’technicalsupportteam.Theaddressissupport@.Atthebeginningofyouremailcontent,youcopytheinformationyougetattheheadofyourlogfile.ThelogfileisafilethatyougetwhenyourunSAS.Itlookslikethis:

NOTE:

Copyright(c)1999-2001bySASInstituteInc.,Cary,NC,USA.

SAS(r)ProprietarySoftwareRelease8.2(TS2M0)

LicensedtoUNIVERSITYOFXXXXX,SiteXXXXX.

ThissessionisexecutingontheWIN_MEplatform.

IdevelopedmySASskillsmostlybycommunicatingwithSAStechteam.

IoftenuseGOOGLEtogetanswerstomyquestions.IthinkSAS’shelpmenuisnotveryeasytounderstandbecausetheydon’talwaysshowyouthebestexamples.

InWindows,youcanactivateSASbygoingtoSTARTALLPROGRAMTheSASSystem.Confirmthatyougetthreewindows.

1.

Clickthismantorunyourprogram.

Editorfile.Thisiswhereyouwriteyoursyntax.

2.Logfile.Thisfileshowsyourerrors.

3.

Clickonthis!

marktocancelwhentheprogramisrunning.

Outputfile.Yougetresultsinthiswindow.

ClickExplorer

tolookatthedatasets.Seenextpageonthis.

Thissyntax(youtypeinintotheeditorfile)getsyouanexampledatatolookat.

dataabcd;

setsashelp.Prdsale;

run;

Youcanlookatthedatasetinthiswayifyoufollowthefourstepsbelow.

Lookcloselyifthereisanyirregularityindata.

Notes:

Ilookatthedatasetstocheckifthereisanythingwrongwithit.Youmustclosethedatasetsbeforeyourunanythingelseifthesyntaxyouwroteaffectsthedataset.

Togettheviewabovewhereyoucanexaminethedata,followthefollowingsteps.

3.Click

Workorotherfolders.

2.Click

Libraries

4.Click

Thedataset.

1.Click

Explorer

4.Assigninglibrarynameandcreatefolders

YouneedalibnamestatementattheheadofyourSASprograms.Withthese,youassignnicknames(libraryname)toindicatefoldersthathostyourSASdatasets.Forexample:

libnamehere"

C:

\TEMP"

;

libnamethere"

\"

Runningabovecreatestwofolders“here”and“there”inthelibrariesintheexplorer’sviewasyouseeinthepicturebelow(Seepreviouspagetoseehowtogettothisview).

ImaginethereisadatasetcalledMYDATAanditisinC:

\TEMP.Youcancreateitinthisway:

datahere.MYDATA;

X=1;

Thissillydatahasoneobservation,whichisXwhosevalueis1.BecauseyoudecidedtocallthatfolderbyanicknameHERE,youwillbereferringtothedatasetas“here.MYDATA.”Forexample,toprintthecontentsofthatdata,youwilldothis:

procprintdata=here.MYDATA;

Toseewhatvariablesareinthedata,dothis:

proccontentsdata=here.MYDATA;

Whatareotherfolders?

SashelphostslotsofdatasetsthatSASinstitutesshipwiththeSASsoftwarefordemonstration’ssake.IhaveneveropenedSasuserorMaps.“Work”hoststemporarydatasetsthatyoucreateasyouprograminSAS.TemporarydatasetsdisappearifyoucloseyourSASprogram.Permanentdatasets,ontheotherhand,arethedatasetsyoucreatetokeepevenafteryouturnquitSAS.Nextpageelaborateeonthesethings.

Herearesomesillyexamplesyntaxtoshowyouwhatthefoldersdoandwhattemporaryandpermanentdatasetsare.

/*libnamestatementsjustneedtooccuratthebeginningofthesyntaxfile*/

\TEMP"

/*thiscreatesadatacalledWallyinWORKfolder*/

dataWally;

x=1;

y=2;

z=3;

Clickonthesefolderstofinddifferent“Wally”datasets.

/*thiscreatesadatacalledABCinHEREfolder*/

datahere.Wally;

x=4;

y=5;

z=6;

/*thiscreatesadatacalledABCinTHEREfolder*/

datathere.Wally;

x=7;

y=8;

z=9;

/*Useprocprinttoseethecontentofthedatasets*/

procprintdata=work.ABC;

procprintdata=here.ABC;

procprintdata=there.ABC;

5.

HowdowecreateSASdata?

A)CreateaSASdatausingaSASsyntax

Ofcourseyoucancreatedatainyoursyntax.

datakaz;

inputID1SEX$4-9height13-15;

cards;

1Male170

2Female165

3Male

4Male168

5Female170

procprint;

B)CreateSASdataVia.Ms-ExcelSheets

Thisusesthefirstrowforvariablenames.Thenusethissyntaxtoimporttheexcelsheet(C:

\mary.xls)asaSASdataset(JOHN):

PROCIMPORTOUT=JOHN

DATAFILE="

\mary.xls"

DBMS=EXCEL2000REPLACE;

RUN;

/*Thisoneignoresvariablenames.Italsospecifiesthesheetfromwhichtotakedata*/

GETNAMES=NO;

SHEET=”Sheet1”;

Besuretoclosetheexcelsheetwhenyourunthesyntaxtoimportit.Otherwise,yougetthiserrormessage:

ERROR:

File_IMEX_.'

Sheet1$'

n.DATAdoesnotexist.

Importunsuccessful.SeeSASLogfordetails.

TheSASSystemstoppedprocessingthisstepbecauseoferrors.

C)CreateaSASdatasetviaanexternaltextfile

Imagineyouhaveatextfile(say,kaz.txt)thatlookslikethisinyourCtempfolder.

Ifyouknowwherethedatapointsareexactlyinthedata,youcanindicatethelocationsinthefollowingway.

infile"

\TEMP\kaz.txt"

;

Ifcharactervariableisjustoneword(e.g.,Male),thenwedon’treallyneedtotellSASaboutexactlocations.SASwillconsidereachblockofwordsornumbersasonevalue.Butyouneedtosay“missover,”soincaseSASwon’tencounteravalue(asinthethirdobservationinthisdataset)atanexpectedplace,itwillconsideritasamissingvalue.Ifacharactervariablecontainsmorethanoneword,thenusethemethodaboveinsteadofbelow.

missover;

inputIDSEX$height;

DataStepsandCreatingNewVariables

6.Examplesofdatasteps

AnySASprogramconsistsoftwoelements.OneisDATASTEPSandtheotherisPROCs(suchasprocprintorprocmeans).Idiscussdatastepsinthischapter.Ishowyousomevariationsofdatasteps,soyouunderstandthembyexamples.

dataxyz;

setabc;

/*heremanipulationofdata*/

dataabc;

sethere.abc;

datahere.abc;

setxyz;

datathere.abc;

Reminder:

Temporarydatasets:

FoundinWORKfolder.Theydisappearwhenasessionends..

Workfolder:

ClickonExplorerClickonLIBRARIESClickonWORK

TheHEREfolderandTHEREfolder:

HEREandTHEREarethearbitrarynamesthatIassignedbygivingLIBNAMEstatement.TheyrefertopathsthatIspecified.

7.Manipulatingvariablesindatasteps

WeuseaSASsampledatasetsashelp.Class(adatasetcalledClassstoredinSASHELPfolder)topracticecreatingnewvariables.Dothistofindoutwhatthisdatasethas:

proccontentsdata=sashelp.Class;

Yougetinformationbelow,tellingyouthatthedatasethasAGE,Height,Name,SEX,andweight.

#VariableTypeLenPos

ƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒƒ

3AgeNum80

4HeightNum88

1NameChar824

2SexChar132

5WeightNum816

Hereis

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 工程科技 > 环境科学食品科学

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1