超经典的SAS BASE的笔记5Word下载.docx

上传人:b****1 文档编号:3683667 上传时间:2023-05-02 格式:DOCX 页数:28 大小:34.98KB
下载 相关 举报
超经典的SAS BASE的笔记5Word下载.docx_第1页
第1页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第2页
第2页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第3页
第3页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第4页
第4页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第5页
第5页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第6页
第6页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第7页
第7页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第8页
第8页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第9页
第9页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第10页
第10页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第11页
第11页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第12页
第12页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第13页
第13页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第14页
第14页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第15页
第15页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第16页
第16页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第17页
第17页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第18页
第18页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第19页
第19页 / 共28页
超经典的SAS BASE的笔记5Word下载.docx_第20页
第20页 / 共28页
亲,该文档总共28页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

超经典的SAS BASE的笔记5Word下载.docx

《超经典的SAS BASE的笔记5Word下载.docx》由会员分享,可在线阅读,更多相关《超经典的SAS BASE的笔记5Word下载.docx(28页珍藏版)》请在冰点文库上搜索。

超经典的SAS BASE的笔记5Word下载.docx

∙comparison

∙logical,orBoolean

∙minimum

∙maximum

∙concatenation.

Whenusedtoperformarithmeticoperations,theplusandminussignsareinfixoperators.

2.InfixOperator

2.1Arithmeticoperators:

ArithmeticOperators

Symbol

Definition

Example

*

multiplication

wherebonus=salary*.10;

/

Division

wheref=g/h;

+

Addition

wherec=a+b;

-

subtraction

wheref=g-h;

**

exponentiation

wherey=a**2;

2.2Comparisonoperators:

Thefollowingtableliststhecomparisonoperators:

ComparisonOperators

MnemonicEquivalent

=

EQ

equalto

whereempnumeq3374;

^=or~=or¬

NE

notequalto

wherestatusnefulltime;

>

GT

greaterthan

wherehiredategt'

01jun1982'

d;

<

LT

lessthan

whereempnum<

2000;

GE

greaterthanorequalto

whereempnum>

=3374;

LE

lessthanorequalto

IN

equaltoonefromalistofvalues

wherestatein('

NC'

'

TX'

);

ornumin(‘3’,‘4’,‘5’)

2.3Others

2.3.1INOperator

TheINoperator,whichisacomparisonoperator,searchesforcharacterandnumericvaluesthatareequaltoonefromalistofvalues.Thelistofvaluesmustbeinparentheses,witheachcharactervalueinquotationmarksandseparatedbyeitheracommaorblank.

Forexample,supposeyouwantallsitesthatareinNorthCarolinaorTexas.Youcouldspecify:

wherestate='

orstate='

;

However,theeasierwaywouldbetousetheINoperator,whichsaysyouwantanystateinthelist:

Inaddition,youcanusetheNOTlogicaloperatortoexcludealist.Forexample,

wherestatenotin('

CA'

'

TN'

MA'

Example:

datain_ex;

inputstore$vcr_pricevcd_pricecd_player_price;

datalines;

future_shop169.9969.9979.99

sony_store179.9964.9984.99

radio_shack159.9964.9969.99

three_d174.9967.4974.99

electron174.9965.9969.99

datain_ex_2;

setin_ex;

*where/ifvcr_pricenotin(159.99,169.99);

run;

2.3.2Fully-BoundedRangeCondition

Afully-boundedrangeconditionconsistsofavariablebetweentwocomparisonoperators,specifyingbothanupperandlowerlimit.Forexample,thefollowingexpressionreturnstheemployeenumbersthatfallwithintherangeof500to1000(inclusive):

where500<

=empnum<

=1000;

YoucancombinetheNOTlogicaloperatorwithafully-boundedrangeconditiontoselectobservationsthatfalloutsidetherange.Notethatparenthesesarerequired:

wherenot(500<

=1000);

2.3.3BETWEEN-ANDOperator

TheBETWEEN-ANDoperatorisalsoconsideredafully-boundedrangeconditionthatselectsobservationsinwhichthevalueofavariablefallswithinaninclusiverangeofvalues.

Youcanspecifythelimitsoftherangeasconstantsorexpressions.Anyrangeyouspecifyisaninclusiverange,sothatavalueequaltooneofthelimitsoftherangeiswithintherange.ThegeneralsyntaxforusingBETWEEN-ANDis:

WHEREvariableBETWEENvalueANDvalue;

Forexample:

whereempnumbetween500and1000;

wheretaxesbetweensalary*0.30andsalary*0.50;

2.4Booleanoperators:

AlsocalledLogicaloperators

&

orandand|ororor^ornotnegation

TwocomparisonswithacommonvariablelinkedbyAND(operator)canbecondensedwithanimpliedAND.Forexample,thefollowingtwosubsettingIFstatementsproducethesameresult:

∙if16<

=ageand/orage<

=65;

=age<

2.5MINandMAXOperators

UsetheMINandMAXoperatorstofindtheminimumormaximumvalueoftwoquantities.

2.6ConcatenationOperator

Theconcatenationoperatorconcatenatescharactervalues.Youindicatetheconcatenationoperatorasfollows:

||

Forexample,inthisDATAstep,thevaluethatresultsfromtheconcatenationcontainsblanksbecausethelengthoftheCOLORvariableiseight:

datanamegame;

lengthcolorname$8game$12;

color='

black'

name='

jack'

*game=color||name;

game=trim(color)||name;

*putgame=;

run;

ThevalueofGAMEis'

blackjack'

.Tocorrectthisproblem,usetheTRIMfunctionintheconcatenationoperationasfollows:

game=trim(color)||name;

Thisstatementproducesavalueof'

blackjack'

forthevariableGAME

data_null_;

month='

sep'

year=99;

date=trim(month)||left(put(year,8.));

/*PUTfunctiontoconvertanumericvaluetoacharactervalue*/

putdate=;

3.SASexpressionandConditionalexpression(WHEREandIF)

IFexpression:

TheIFcommandcanonlybeusedinaDATAstep.Thismeansyouarecreatinganewdatasetthatincludesonlytheselectedobservations.OnlyobservationsthatsatisfytheIFconditionaresenttotheoutputdataset.

WHEREexpression:

isatypeofSASexpressionthatdefinesaconditionforselectingobservations.TheWHEREcommandcanbeaddedtoanyprocedure.OnlyobservationsthatsatisfytheWHEREconditionareusedbytheprocedure.UsingtheWHEREstatementmayimprovetheefficiencyofyourSASprogramsbecauseSASisnotrequiredtoreadallobservationsfromtheinputdatasetanddoesnotchangethedatasetinanyway.

4.1Mathematical:

ThefollowingisabriefsummaryofSASfunctionsusefulfordefiningmodels.

ABS(x)theabsolutevalueofx

COS(x)thecosineofx.xisinradians.

EXP(x)ex

LOG(x)thenaturallogarithmofx

LOG10(x)thelogbasetenofx

LOG2(x)thelogbasetwoofx

SIN(x)thesineofx.xisinradians.

SQRT(x)thesquarerootofx

TAN(x)thetangentofx.xisinradiansandisnotanoddmultipleof2.

4.2Statistical

Kurtosis:

describesthe“heavinessofthetails”ofadistribution

Skewness:

measureofthetendencyforthedistributionvaluestobemorespreadoutononesidethatother

MaxandMin:

Mean:

averageisthetotalofsumdividedbythenumberofscores

Median:

thepointthatcorrespondstothevaluethatliesinthemiddleofthedistribution

orthevaluethatdividesadistributionexactlyinhalf(3,5,8,10,11).Itservesasavaluablealternativetothemeaninthespecificsituations:

a)thereareafewextremescoresinthedistribution,b)somevalueshaveundeterminedvalues,c)whenthedataaremeasuredonanordinalscale(seeexamplebelow)

Range:

maxtomin

Sum:

Variance:

measureofvariability

Std:

standarddeviation,thesquarerootofthevariance

Stderr:

standarderrorofthemean,stddev/thesquarerootofsamplesize

dataincome_1;

inputregion$1-8income;

cards;

Edison99800

Edison109800

Edison120000

Edison96500

Edison90550

Edison115000

Edison142500

Edison73000

Edison79850

Edison55890

Edison23000

Edison19800

Edison82000

Edison76800

Edison39800

Edison22800

Edison58650

procunivariatedata=income_1plotnormal;

varincome;

procchartdata=income_1;

vbarincome/levels=8;

dataincome_2;

Edison11800

Edison29800

Edison15000

Edison26500

Edison39550

Edison22000

Edison62500

Edison83000

Edison29850

Edison35890

Edison53000

Edison72000

Edison36800

procunivariatedata=income_2plotnormal;

varincome;

procchartdata=income_2;

vbarincome/levels=10;

5.SASTimeandDate:

5.1SASDate,Time,andDatetimeValues

KeyConcepts:

SASdatevalue:

isavaluethatrepresentsthenumberofdaysbetweenJanuary1,1960,andaspecifieddate.SAScanperformcalculationsondatesrangingfromA.D.1582toA.D.19,900.DatesbeforeJanuary1,1960,arenegativenumbers;

datesafterarepositivenumbers.SASdatevaluesaccountforallleapyeardays,includingtheleapyeardayintheyear2000.VariousSASlanguageelementshandleSASdatevalues:

functions,formatsandinformats.

SAStimevalue:

isavaluerepresentingthenumberofsecondssincemidnightofthecurrentday.

SASdatetimevalue:

isaspecialvaluethatcombinesbothdateandtimeinformation.ASASdatetimevalueisstoredasthenumberofsecondsbetweenmidnightonJanuary1,1960,andagivendateandtime.

optionsnodatepageno=1linesize=80pagesize=60;

datatest;

Time1=86399;

/*datetimevalue*/;

formatTime1datetime.;

Date1=86399;

/*datevalue*/;

formatDate1date.;

Time2=86399;

/*timevalue*/;

formatTime2timeampm.;

procprintdata=test;

title'

SameNumber,DifferentSASValues'

Output:

ObsTime1Date1Time2

101JAN60:

23:

59:

5920JUL9611:

59PM

HowSASConvertsCalendarDatestoSASDateValues

5.2Two-DigitandFour-DigitYears

IfdatesinyourexternaldatasourcesorSASprogramstatementscontaintwo-digityears,youcandeterminewhichcenturyprefixshouldbeassignedtothembyusingtheYEARCUTOFF=systemoption.TheYEARCUTOFF=systemoptionspecifiesthefirstyearofthe100-yearspanthatisuse

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

当前位置:首页 > 总结汇报 > 学习总结

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2