You are on page 1of 72
n SAS; Stotistical Analysis Sof turare | System SAS fentuges! cs Dada Management Go Data Analy ais Gid Cote ating ke ports a Vos ables Columns ; Rows + Ob ren vatiens SAS Notes ao Thee are Saad — Gaze 2 Steps in SAS, cs dota step Gy proe Atep > precede, Procemes a given Lotarsel g Rowdata + data Atep > dotaret —» proc Step 2 Neponds Dataset > beta Pondion 9 proc print Bercouptive Pontion —>» proce Contents piece Contents data = Aarhelp.—all- 5 Contents ab au the on; fl punts the clatarets. a data new newt; y Ths will Create 2 new Hataredrs. impet name § 9 ; Candy; on catalines > J Statement Tewminadon Hahul 50; rum | , a Libraries ate oy 2 types: 62 fermanent Li boon tir Tempenony Lonang 9 Wonk, wns th te default a On GEEIMEEIEVEOD tun! Use 200. a Tn memenic Vaueble a well +he GEES 6B, bab ratemally st can Henud Upde 12 chayacton Ty ad as 4t uuu Head in no ee prunding , proce contents 5 stunzy we Can ree fhe Jeng th qf the Variables, 6 Variable alini bites, we have a tedel of & variable ot ru buter, ti Nome — Gis Lebel civ Lente uv Type Fosemat GW) Im format 5 Naming Varwables and Datasets G) Variable and Sataset name Aboud atart uth cae waite chonacter and wend escone, db we Cannoq Use nemben of the find place in We Comnot wee any Apecttal Chonacters exncepd ander See. (y he Vauable name length ua opto 32 chanact- ow ; Tene suler alo opy f Lbray xame except Library ames Cam only be pds $ characters. a Infile options: flowover, musrover, Acanover, pixsdebs, obs, dlm , ard +t while enteu dota uring Candy at dotalines Aa oie es EC Ot Cara by dine. “Tix pHocem as Rmewn ar flowover, Flowover 3a olefault Phexomenon dain tHiak 5 infide Canals flowoven > MH Even «4 we dord mention in pet Center $ tual $ sub; Pfs SAS user Conds; flowcver while wteoding te dot. oppello phasei 72 nims . 641 2 2 prrce bint dada = drial ~ +un; 2 “imam oven 3 Te any Value 4s mining we use a ood: coat ty we dont wand 4p use dot We Can We TMurover, Synton ds Aame on { ewover VE wit only use, fer the last Yolue in mm Mmbut observation. murover uu farce SAS do ge te the nent Line Node: Aeamovert: ured bikie date while im podtirg , data tab; tore semi ve, we dont we imple neye tnput @ ‘Core? trialf Aub; Costly 5 appolo Phavet w 7 entuat Me Cone Phase 23 Coxe volyes nim Pharez 93 : 5 Y pe Punt datas lob; sun; Tn steel Lime we denp ure Acaneven, we only use Grdjicnal Atude ments, delimiter, blank space wt» the default de Lian] dad = data Aemitive delimitur data stand on 5 Inple Cardy dlm= ‘so’ I New Gmma uy be input vant vanr2 vers; Conrideyed a delimiten Carel 5 er mcy ies we fam alo we dsd, 7, 2,3 rnpile Cards And } eames up tb gets lion Corman Proc Prints sum; Ari'maud fomerunly tt aul tore the between volue ana eae” Uolue. atdsd can Head Commas and quotations, Bere moke 1 PauiciAr uml aA po ( file Cardy eee a Rin ty another pain # whem we ove Wing dim, @ blank Apace 1% not a defoult delimiter avy mane, we wit hove tb imped a ablonKk Apace | as sell. % we com use cllm and dad together as well, eg: imbile cards dim = ‘$,@? dod j a Bring ing data from cutride yrom tent fle data df; 4 we need to speaty ollm ar well ip mple file path? 7 'r the Gle the delinuter us nod maput Vor! van2 Var 5 Dpate. Jum 5 Thr seads tab Apace data df ; g ay elms ox Sree ara eee eee eee eraseeee Cag Cee eee eRe SeeEEEEEE Pease Mere aemeceeerre me OD put vant vo12 5 Mun; pret obs amd obs iy Atert yeading from 21 oby Pre and eae Lil ee obsewvealion imple (file path? fiwdebs = 21 Obs = 30; imput vehi vor2 end; sum; deme ee 4 Sp we do not provide chs, sf ull Atont reading fim oUt obs and Head Hy the end. wnang im fle we con eat tomb eset tnt files - oO filename wie (pile foam > evteating a tefenence dotn dt; for the pile pork. infile obé alm = Sov n: mp ur Voxt your “or 3? ra - Fnccued dy L un iP 2 eco etence + fle namer and Sa) mame we olernt need do use amy port 24 guetecions A Fonmats amd Em formats a There aye 2 type 4 dam, Stam dand Doda zs Purely Lelio and Numbow Non Standard Oak: wie cam do seme Caleulation ie dote , time , amount # SAS an stead Aetamdand data o%mally dud sf 4s unable to tead non- Standard dada. data df 5 im put gdlate $ Adede $5 Was ual yead aa chayacler Cards 5 Variables, Howevey we tod 22] 02] 2019 222 feb 2018 be able & poyonm colen- Yan ; lofiom | Shese Uoluer. Pswc Pint, stuns 0 formats ; Converts Standard Sata do Non Stand and dota (Pa foamed 2 Comets men Standand doin to Ltand oval dota. O de fault Format, Sud In formats 23] 12] 2003 a3 -12- 2003 ddmm gy 0. ddmm gy 1. dd mm yy o- ddmmyy Do. 23, 12. 2003 ddmm yy to. ddmm ay Plo. sal beers, ddmm oy 20- ddmm yyc lo. 23 228, dd mm™ yy 10. ddmm yy b10. 12] 23/18 mm dl gy ee 4 8 chayacton = ¢, 12, dec 2003 date F. I2- dec - 2003 date i. 12 dec 03 dote 7. aX, The clota input Code wail wow be, ye god” ab at Cee dota evs; we te Me Lal Sat nt MOLT owe poe go ingermot jdote ddmmyy10. tdate date 9. 5 cards: format jdate dated. Ldade ddmm yy 10 5 22 orf 2017 22 feb 2018 tun 5 Pree pent > son 5 Seeeereeee reese Pe eee eneeeeeiee Sap mnnetre ir corer mmm Has eee ear erect Atoiement — thats Fi the od pet ull Cae ar | be the Note in fosmat + ie) ee Olas ea oe b> blank Apaces- p> pericds Psi pee ety (default) Cp Colow l re 23fI2] 2003 <=> ddmmyy t0- Sy ddmm gy Aso. “he feumat rtutement goer gt belo the informal aetrtement. . wt Ris fosmat oil apply to belA of these“ , No need te mention separdey «f the fermats aHe Aame. format jdate Idate ddmmyy 10.; wt doin new; input jdote: ddmmyyl0. Ldate : dated. 5 (poate pee Ldate ddmm gy 10. 5 Candy; I No shortcut for format Atutements we 22 [ orf 1160 22 4$eb 2018 hove to avude foxmat. tun 5 prtee point Jun 5 Dade Valucs Injosumat Foumat fan o3 pcre) 5. mon gy 5. Jon 2003 mon gy 8- amon gy 4- # TY tm infounat we ure amon yy 5. but en formed we ane Usi ddmm 4y 8. , 4# wut ag dle fault punt 15+ aw the date. H Only format Aped fications 7 word dade 18. , WeeRclote 18. week date 24-34, , Oud put erdex ecole eeeicleceee , Jan 1, 2003 julian. > 201k 300, im 2018 we have lo mpdeted goo fer ee time 8. t>meampmio. dote time 18, dateampm 20. time 8. ti melo, date ti me 18. clade ti me 2o. 142 122 30 02.123 30pm 12 dee 2003 214 512: 23 12 clee 20032 10:12:23 pm For dime the Injformat Adadement ty a the CUES 0010100 > 0 H Syntaw tame as date. # Format tute ment Can be used both in the data Alep ay utell ar pC Atop Hewevet, When Wwe ate Wing the Atotement in ota Sp thod ty for the adores purpose. when we oe wong the Atotemert 1 proce step ted 1a erty tae Caveat hese a Aoved in the Lata Saved ia the Lota Bodin Values 25,000 25,25, OD $25, 00d In foumet Comma b, Fostmat Comme 6, Comma 4. eo Mar F- Comma 4. cle Man 4. comma i2.G > Adding decimal places. Ayrton Same or date. Nure ‘npormat simply e-moves the Commas omd dotlen Argn and Aaves in the hata id werds34 —» auiy Apel cut Me amount a data new; i Mmput gdate 5 d-mmupy 8 5 format jdote dd mmyy 10. | candy | & 22 forltF N Chie geo aia a pound 2 oun, Y Input methods : options — yearcud off = L400 - 1199 5 > Global options oe SAS Input Methods CIM) hint IM, Column IM, fermated I, Nameq I) a LAd input Methods: elata L's input name $ Cards; vamai 50 Stan wee can add ar input ethed. geese ee aaa ate eee age gender $5 mole fp AU the Volues Arowtd be Aeponated by otHleast me blank Apace Ce ee se Ea Sie cease Meee aCe Saat recesses mmc cee aeceR cee wring the period. HW the tong te Atatementd has te be ayatten bejare imped Atasement. $45 does not accepts Sat ence a Vvordable mame har been declayed. 4 Embedded blamk space : BlonR Apace MWlin a Sing de Value Le. fie tame and Last name. % stead an Cmbedded lank space te have do woe aw apne end: re. dan dati oy fon declaye the length hee input nome :f $20, age jp so Cartels 5 vamai Ku mo 5e male Se 7 WeHe): when We aye Weng oO the Tet Value has to be Seportt ed fy atleast fis, blank époces a G@lumn tnput methods. Specify the Column, as the vhuable dota cof; al feng 4 Input name $ 8-18 age 1-2 gerd en $ 4-7; Corals ” 13 Mele anki! gaye eam 5 WN Alumys check the porition and type y the vortiable. a Formatted Iuput 1 ctted Hye Wwe Rave +t. declare from where the vacable pemition ts Afonting ond whad ts the fengH-n lpia fon jo Saeed ng Po (a patM leur ete eae age $ 2. @ gender & 4. 5 cards — beng Me 50 malevamei Kumar YF the Vasu able. SO M Limiter to Column txput methed. Notes bericle tery th fe Me yp you wufye 44 mean thar S05 anit” only Stead he HT Chavadoy, a Feth and evew time gm have do ‘npud the vUoiable name. data named ; i) I Pye cas; names Yamrt gendey = mole oge = 40 a a O Output method Semi colon Often each and dota cut 7 y vey va able Mame = ‘Vamni! j age =4o 5 gender = 6m’; ouput, Pia emma oe ages 20; Gordene Sm? aad Poe prumt data = out J stun ; 7 feng tr name $15; YW Were we have fe write “outpul, at the end q eat, chsewetion. Else the Last value Will be eee Scere militar” git gale dita U Tre pirat '™put obsenation ts Comoideted 2s the de fouls fergth. BK hecdify tis Wel have fo Use the feng te Atatement. © Puce format in SAS. mB uper lepined fesemats : Ape af Converaiona, Chonacter de Chanatl os chatacte, ft numeoue num to num mum tp Charact en z : devs Oc. mat f wr’ N CHecling the ferrmat (aac Oe 4 fe value $genden 6M) = “Male? a (p= “Female >; peee punt doda = Sas help-clars 5 4 dpp tying the frumat Aent $ genders. 5 foumed eat Veuable name Feld periods beside formats pee format j NCeteating moltiple farmer eyo, Ay value $ gender ‘M?= “male? ‘f= ‘Female’; chon value fmgen $M? =4 “F225 > chon to num VYolue Rhum A= toot 12 = 12,002; ey nomeuic te numewe Pioc puny lata = 4ashelp.elary 7 Apply the format tern acy eae ale mows | fer enoate sun 1, Adding ~arge vaste ee oe Mle ceca Cl “qouger 13-15 = © (ictedle * ance lenis Numbey fo Chora cher TE we hove Chorayers on dhe left hard Arde we heme tune the (Stag Soui: wn vieeia ee proc fenmat dibrang = Aad user 5 Peronenent{ ral etait Coralia) ato sere, ar Wap cloacae Jim + a Calling She prtenicusty “ebtiew fond semen = Coston; ld Ho dar Psoc pind datas Aerhelp. Clan ; Libraisy format sen frgen- age yumge +} ie Pree format ieee he Aasusen ft Lb ; punts the saved fount. & Glebal opti ens options nocenter 5 has pont the dada en dhe entneme A4t. pitoe print datas Aashelp.clars 5 oun | Woonce a Global option han been Gcivated st uu seman achive thucwph rut she pregram q cee the Cede deed not mean deactivated opti omy Center; 3 deactivader rplion 1 cond Ree Cl CRet ClO Seu cred eee Ove Oe eee aC OS the Global option ars well Removes clade aud Lome v option center nodate Pe ) Ht options date; Pacoly date and time # optims no ruumber jt otros mumbo, G Pepe numb ex a camt oles custom option — pagemo= 50; ong Page oS f options Caps; — # options nocapa; esta me Arye, L4 => 64 [- 2541S man age ne, ps D> 56° - 329097 tna eerie ne hew Geer Choyactery ate Wwe prev nting > Mumba ef knees Fn a Arngle poge. 4 option Ms = 150 5 e fan decneare # optiony My= 150 ps= 0; oS a a options 652150 ps= 30 fimtobs= 5 ebs-10; prec punt datas af: um | Note; we Gomt use fons chs and obs at Jebu Opti ens. we Sorvall Use af ars eu ‘mple option 4% dataset option. WH cptiony — furntohy =1 obs = man; G deactivating firdebs and obd Sesame eee gear eee ean a Gardom tte No mee tr add ception here # footnote “me End? ; H foodmde > ee > . 4 option, Comer = 20° Sohlag fined 20 evens a + opstiony gore ogy = 1120 | default 1126 F100 years se. 2025. ewe Can use Plebal sptionn eveujwheye except the Adatement. te tmride the ola. Tul) here o (BASWDeaRRIOPHS con Fe cred in net Pala state mew Keep » dep, temome, uthene , frdtebs, obs , Heplace Inbel , pavusard , eod from Step love New olefaset ee ee data Clan 5 as peaemore mace! Act Aashelp.clarn 5 Acowce hataset in = wun) ort keop deere VYarinbles vid) : Act clay GREER EURAONOTED j > Vid 41> ecemmen ded Jum > data chant; 2 Both these Codes pe the ame out pot, cata Clam 4. CReap=AMENNAGE) 5 et cla 5 ine © , chata Clans 5 Aet clan ((Giep = Aen heigty weight 2, Sena data Clan2; Remoming Ea) vances Aet cla CRM = Creme And name ine Gordon 3 sum Z data clam2 ; yy Drpostont 4et Clan (whore = Coge >= 14))7 Stow Care Atenas tive + Det clan Cuhete = C5e% = “FD; - cata clan2 7 # whe 1 wed t Aubsct te data. “theye Can be OST Ss enditionel Adotemend 4S well, doda 4S Act clan (ASTD NOTES»; defoultly “4 12 Ye dedr Clan Creplate = no) at bani cally alles el clam ( Ketp = name oye) oo = oletars oA sum * 2 we can anign Jebel far the Vouable ay well ar Sie hates et. Setting Labate - + data Clan2 C Lebe = fde mog Hap hies ee Aer elm C keep = Nome Ver’ hefascet Lobes cata clanz © babes = “demographics” ) ; set clan ( Keep = name ARDS foe name = “Aubject name? eye = ‘neste’, room ; Masuable Iabef data clana C pew urnred = apple ) ; Aer Aeme data 7 ¥ . ~ are wresd me) Aating PO 4 data clan2 C pacaord= 3 Head = 974); 1 Bockend fasocen. dota i mpus- Melhed |” (aput el sal age, Canals 5 fol ooo 25 102 2owd 2¢ data output - mefhod (LS momen ak eee) td = foo; 4eal = 2ovo age any oul-pub* Jum" = 4 Compélation Phores checks for Ayrton outa, ereates temp amemony anen C Poy — Agen daly ve ctu) Aaciges each blecK do Cath Vovu able Aaigus attr budes Data uta not Come tnfo the frictuye tm Compilation phase U cid put Mmetheed Aewce ata -> PDV > outpet Joy lows 25 sq 10D 25 Courped) fol toun 25 Jog 2000 2L 102 2600 2€ Crutput) 402 2ovo 24 Prints the backend dain ins v procen raput td Lol oge 7 put_all—j Cardy 7 fol teed oo mee cep ee Jum* J HN Input Method -» # of iteration =a 4 dota Lines coe OHS Tenner Automatic Variables, 704 -1- Present + owe cola Shey af aoe ONY Acute dat, 7 FIrper Bupper > Poy > output aa aly Me otfsubutes bine eee the actual dala, TE we Uwe Keep, heop Wn dain Adep the feltexalion wit happen offer POV but 1p we “se 4m red Atedement the filtewt>on ek Reppen before POV. we tse Act Ao the filfterotion becom co armpke. a options Nonoters oA cuice - option Noter Aource F Mo Impost ond En part, Used jim proc Atop pwc import clatagile = © Location uth erntencion? oul = 7 olor = aA} sie) SS clotorset name foe impo lotopite = 9 outa trp olbmys clin) vin 5 Fale pe Extension oBmSs Encel =r ( nbn) reds] rb accem mdb (-accth) acen ely meter + tot olim esv pele scsy/. tut cou fab file « tnt tob proc impent datafile =‘ / cut=tut dbme= dim; getrame = 0 5 ven 5 gt Me fond ew ar Bortable nam er by defeult SAS toont ruploce the Aatoned pre impesrt dotofite = 6 ? cut = tui db = lim Qepharey Gu nome = no! 7 Tacs she Str’ i etd datoret proe impor datagile = ©? cut =a dbm = nb seplace’ geimomes = no} eae a ae ee ae a eee ees ie G _ Sheet = CAnect name” fe" get % Specific Aheet He the azade men! Luda 1000 =a > frm De! sow ut atl tee LU the end Dheetrame $ Cyt Sioa Sten) } OP Cell tomge | te dato 4 be mported. tate wring seamge Mo weed t we heel. Mee peed data proc expert cutpile = ' peth, fle name anol entenion? data = 7 dom = dim sHeplace ; Jum proc impart fable = flight cut {4 dtbms = acces Autabase = ' fle path amd entewion? / Sum Proc ermpaxt ocutteble = Ht data = 2 aAbm = acces ; cata base = © hecedian and fle name ? ; oe we Com ure datose¢ Optionn here a well, the dadarset option 4 ued vent to the hotaref name dn brackets uhile importing He file. But do not we seplace as a kata ftionr DB Chatac ter ferction © Upease , lewease, propcare , BEM , Subsin, indent, inden od, Comper , Compbl, sugnt, fe pt , Ataip , trim (ep, (28, (cate , | Cotn » Contatendt on Cu) veury , Gad) ompone , (MIE) co temgith fonction eee dala new | aE: as (thin tn Das? 5 en a= Upeare C ‘thy 1s 4057); uc = Uplae(ay; > Or CHeote a New Variable 4c = toweare Cues; Pe = prwpcare Ca); > Givat Letor of every ward eal be Ae = Acam Cay 5); un Upper Care. 1 Geven the 94 wand fe. "sas" gy a string AC = Acam Ca,-3) 9 Gives 774 word prom the RUS ive “sus By default fn $" compiders blank space and + as Aepar ators a eo CLAY 2a Cae Ly user defined Acperdet, chen we de pine a Aepearotar «f aut net Conrider she default ene, we hove to mention Apace ar well Le. scamCa, 3," 2°); ae Abs = subst Cay 2,2); 4 from a” choyacton ay wil Cemidey 2 ehayjactim te “hit, 27 4+ubstn Ca,i, 1) Ae Peon only ene ehanaden ce “t". We Can Ube thin DH Entuaet Aate ord time Aeparcldy voy = inden (a, 64s’) ) gives the inden prom where (as? as Atenting Ce 3 Mak = indest Lay Sth) ) 5 Hin locks fan te complede werd, tea aut give cated 0 "6% cmp = Compre Ca ‘> snemover, au the Sa, td Can be used do nemove blank spaces econ tallaca Ca ,6 7); on Compre la i's 2S) > tes cui Compre blank Apace onc Ar Tp we dont gre eng" axeguan emt oy default +4 att fompren the blank Apace cbl= Compbilayy Wis mitt der | comp ners blorBs re st win Cempyen multiple Olan Spaces walin a drngle blank Apoce. My wrorkhs om Tab Spates az well. vay = beft lay; moves ever ting te Left ons 20 ver bunk spaces fe tight - sagt Co) cloes the sfsparije dep . . B J fin 4a Aw de cnet) Roi blank spaces blamh pacer vor = Ateup Cay; “temoves beading and fora Ling apaces Von = fu mla) ; %o-moves cae treat Lng blank Apacer, Sac ty 2 > era ae as > es Aa» yy var = Cat Ca, b,c), Combsnes 4, 6,6 o> tt 9 uth blormk Apres. = cats Ca, b,c) 7 does the Ce Cott Aknip F Ly Huy 4s Aas von van = Cott (a, be) | > Cat ¢ Pum, wemoves trailing Apaces Ned ono ETT a) 5 © dite = b= Sp GPR Co YY, R06 ge)5 D Hin 4th neo entn = allbic ~~ works Like Cot #7 However the vouable frye adu be the Aum oy Ary ea in the Imp ud eu able von = Afvup Can bile ¢ vou = Adsup lay MN 6-2? HW tramcb) ic 5 data Cbin 5 STRINGI = “ Helto Gretoye hello“; = 4 Pie STRING 2 = Hello" ; voy = find C Gaara tring 2); Seon ching Atding2 im tring oud put sy 1 Ccare enaitive) wan2 = finde C Ata), At sing 2 , et K- mocks fret ¢ Give te inden ftom udgure the tnde mes cle not made vay S = find ¢ Ateimgl, Ad sung 2a ws vatng a mo fi or fe. 44 aul roanone the Case. gets fue 'ndem of font aad ch 1504 eapecti ve os 4he Case. vanrg = find 2 eee “abe, coe neores boot 4 chonactory and atorto finding abe” prom Me StH ahoyoder. Sdoing Ca ATEICExtAV BID ia Pee Le vay = veu sy C Strung , PID) Give value 3 trmlan Een ford c Vor = Compote C Sheu ng , ff) E eem pores the Alcor, output identical tm verify. Cot = * thin 44 4a) van = tran uv C Coty (Hay? , 6 theye? JF Replacer Stir with there in Caf and aves untp Van. vari ele = ei ea Cat) j give the beng ty 4 the vatiable | dtere eutpud ail be I a. neme nevor adi tya derh pandey A. beoh Pancley Kaman otsfen — vredaly Ks Argun — Re daly ‘Re neva Se Tie Ahovld not exceed 50, (WRERD che crreces far dercncpencies Ans « closn new > input fname: $$ 35.3 cancls acl tyn dent pancey Rumer nj un tre boly seu 5 dota new 4 > Bet cree a= pucpeare C fname); b= pubadn Ca, 1,0 | G = imden Ca, © CD > giver inden 4 the fires blank Apace el = Aubsain Ca, ) = Atuip Ce) i &, Bas Atrup cd) 7 cheep Bees aa my wen teoing tm the chadan ef | Option we hove fo ure fut (ae eehd brackef Vat alle format. a Nemeuc ptunctiom int, cy ceil, gloor, tag, tog 7 beg 0, fact, abs, mod, libt data Apune 5 input 24> Canals 5 12.34 15.56 34.84 32.14 ~ 10.32 viens , «1), sound C%) 61 stnd = swund ( abs C*)> ahoolute fed = facto,’ f dog 608); Abipts one value down te first sow ws a = cera an log Jo Cx) q 4 = mod C%,2) > Hemainder Shen 2 [> qe di fp 6%) > does Aubtoacton fo 2 conreculi ve Volrer, find How ty empty dela Appas japee 20 Glee 5 Candy 7 oo t bee Za see 3 eI B 4. 4 Ba Oey 2 SiS pCa 2k eG oata new ; Aet oppu; de Aum = BB (OP 14+- q10); poets MMM C0207073)0 2217122) cry Aum mean Cop 91-2); suum = (in) CBP) 2! - 1109; Aum = (mane Cop 7 on ILOy) amar? Au the shove Shovld be function addy up Columns o% Operates on Columns, Ty we want fo operate om stows we have 4 mentizn in the proc atep. Proc prunst 5 fay GO BF MED aa Jun ; [ Rea f= Cc, Cemep cw , CRB) Date ond time funetinno data new 5 tdy = (fe day ; P Current date ty = RECS, 06, 2018); +4: - a - ém = GRD 3 cane time md = (EBB 064,05, 20) = OU Frvmet tly tly tty (RE em tm tm EE Stun j data teat} PPT eta eee eee bate = today 6; O72 = (ARAB CBR, 5, 5, 30); Syntan Oo ACU lees COMO + Aye = A (GREE 6 008, vate, (REFERED) 5 format Date 008 MEM) D7 O12. CORRE. ; tun titte * bhicachinng Cf Oct Sg STS proc pount; sun, gu = inter ( ‘year’, bdate , Avdate) > y p Input dates we yecd ge clyz erence = intce ( Smonth?, bdate , Svdate) = inten ( doy? » bdode , svdate J Avdote + 14 ¢eb 2005 Avie > 10/23 545 bth me -> 17 man 1978 212 534 245 ky = (ABYC svdate) / mn sc (PREPAC otod 0) F get = GRR Cavcates | hr = (Re C4vtime ; oun = GENIE C sv time); sec = (BURR) C Avtines, dp = (ARHRpaA C bel time) ; tp = (ERMPBE C bt time) ; fevmat dp deted. tp dime 8; run; Put 5 Chan, format Enput > Num, infermat input x$5 -» Note Mat x ty a Choyacter type van tan cls 5 tut, mambenr, tf we Mand 42 de , Colculediens om St we won't be able dFo- ame bo we Awe #4 thea dota Gp 3 Conversion wing Drp ut 4.9 dun 5 data new at gS num = input (%, best 12) 5 Mt Fos wwmeric vauables the ee itectewule | ee) fte) cat (i Gen perce pound; Aum mam 5 arreae Fou Choyacter Variables Wholevey : eee eee Chey = put Cram , 41) / g f= wad ea esa = width. decimals (eC 's er ser ts co on PY ei decimal point. dota new; in pot dates ddmm yy $0. 5 format fdate coded. ; Coredy + 04 foafrorg vtun 2 ia Ee A re dot d J Chay = put C jtte, ahd omm yy 10.) 5 num = input ( fdote, date?) 7 sium * mumetic “uth feng tn & a ‘te “proc print" proceduyes Mobs, double, heading , width, tabel (option) Aum ven , id, Label, by C statements) proc pount = data = Aerhelp. clan noobs ceuble > me 7 J Adds Afooce Remoyes obsey volion a. hremili ng = Yoertical by de fault 44 22 hessgertel, heo ding GF Column namer uiclth = full —» Imonemres spate betucen Slumnr by default width= minimum Pc print data = Aarhelp. clan * sum age A var age ; prints rly age wonko Like a Keep oplien sn dase Adep fd age; hetp ue Set the audey the Variable tm outpd Here age alt print port. eh age sen 5 vtum j Farot ae then Acme v % ure label Proc pnt dota = Aorhelp.clan Lobel, : ce Sar eeaaersiaee Jabel name = © name of he Dubfect',' a label mame = © mame of the subject 7; v + Ll . j points in AGparate Lines pe ext. prec Aart datas % 7 > Bh moker ear eo in ee the augenal hotoret . thor, fuen abaiays pronide out. buoc sont data = otf out - ndf 5 ty oge 5 no chang eo tn the ald Lada Hom 5 ae by default 4m arcending ander prec Bont dag = YY out = clan 5 by Aen yes foot Awd ll tem then uutin su | Aen Bort - Scie pxec Aart dota = dy oud = clay ; by dercemnding Sern age; es fits sented in mcending GEEEEIES) Dp we part a Voriable athich har ealgatct values , Tumbers , epecial Chonacer hen the — orcencding archer wk be Ciera mae ea Special Character Hee cena 7] wa Numbon dene bored om Se errer esa ree stew eee eee ag tem reese ee ne dmay Seton 2 Re mouing Cuplicades prec Det cata = ebmcoldata out= mew nodupk ey ; ey) ta Eee Ce CH fata on Hewrd A wiginel end Aecond on ar ) duplicate. proc Aant doles clinical data ort = nes modu =: by pidy Jum > a dow a he _finat necond ar _dupticod e reel batty ais and +eteord one avu'g4 nad Cven if we have 72 te cose free pont dota= dft cut = Ho (esepy by pid; Tn no duptey only the /mesdioned ow able 42 aaa ehecket , but here the whole necond i ie Checked. et noduprec " and noclup "> rove Proc Aart datas offt cut = oo mecup Key » cece rh es SPC / Mee yun; Grouping %f vastiables. we Mont Pv'milon MeConole together Based on a variable dotq ot 5 im put «eoulf von 5 Cascola 5 ACTREL 4 TNH ZI HBN) 2! Ane Ecame Jun 5 eC ole we Cant mse by Ateteanend by Mend) wuithred Aarting the variable say pre ret data = Chincal ut = neo; ae) ~~» Ren ts brde then We cio Can Mieista by. pHee pong by vari; Fun 2 oe Thin grouping code vai new wour proc point 5 (by Cemd e% 5 Gvteup by ee Seponode GH cet 7 ges 4 Proc pant 5 td cemtery > bringy c3ontey de the gonad by Comte; > Goups by Consors oneal data fiend 7 Aet clon 5 fd gves) 2 oly take he fiat values in age iE Bote sge, often derting. ip lasteoge 5 —> = feke the lant volue data fiat j Ad clan | by age GP GER je HR ep che Aeqno ty vin 5 toc Print” sun 5 yi »» qu the F ef stecords fh Dain Management Pree : Apend, Cencatenation, Intorteauing , update, Medi fy , Meoge Comider 2 dataseya Labs; i pid age sobs2 5 pid age Web et Jot 3h fot 25 t ropa rg) 103 at 2 fo2 28 4 AU the procedutts above we will unite in clan Atep only (GEA oe win GatteuAyPee sre prec append dat = toby t bane = Lobo 2 ven; Pees naster dataret Tz we Reep om enecuting the code it wit Recep on deli’ 9, Master dataset Should aluiny> Mave equal at mane Gl Naniables uthen <0m pared tp Child datrsef. TA Lucy a Acenatio Ube force. eeu eae seca eee eee eae See eee eee ameeermeeT eae EaeeeSEe eee ae . canta > Baty of these Codes eu Wang + P10ee oppend lata = tobs2 bape = Lbs 1 Cbwp = Paid) Htun® But farce 4h tecomm ended data [abs e J tet lobs1 Lobs2> Tin wn Gated labst ond Labs2 stun qn vn tabs. dheernt male how many hm you yun the Coele, t4ly n04 ade Prec Sort data= Lobsi ; 4 pid, sum; proc Aart Anta = Labs2 5 by bid 5 sum 5 hota babs > Act fabs! labs; concate nation “Airg patierd by pid, del. stuns Concate nation ¢ Limp Y lol Fatenten wing, ert anul add uinitd > Pld ose ait 2 > Pid dove $ awa f Jeo 5mg 100 ISrg atic 101 lo mg 103 omg had 104 5 mg 102 de mg hyd 107 ed 7) nga Prec ont date = wait t > by pid) sun; Ptec ant ata = uiris 2 5 by bid | sun; cata ubsitj update wirifa winit2 | updates windy 1d euth wart 2, by pie > Fncose we wary f uplode Uinit2 with ait t Bi proc Print; sun > update we awute waite Wired 4; Pts code Updater wit, new values and old sen - courting However ip aminving volue ws there th one wf ugh 0+ the value. Of fhe asorels arising Values, Tt will fake on enishing dota init } update und 2 1 | eA - by pid; ; Tas ett tape m« Jtum 5 Value now amd went update with a New value. dota lobs2 > modi ty de 4 ot the coe ege = age r2y ee Ytun > u Saeed Atatemernt Trare tusd namer 4hould be Aome, However this ua Chonge the oui gi nal dotereh» Tn Corse we tant to 1etain Oot ontg inal date and CHtcode a ome we use Let state ment. In new Types of Mowe : tis one fe one mentge ( Without selection) “oe de one mow © Cath steledion) city ene to many merge Curith selod om) uy ices fa enes Menge) Gucth vtel etiam) (ws Many te ay gicecane Cart Kelstion) Pca secs sats eee eee Feed Sree eee emg eee eee 11-23 i 102 CUNY Sea oz a 104 i as to Jog 24 iF to 4 6.2 2 Loy 29 ad eee. 64 42 105 30 Fe 105 w 6.0 So data new { Tun Code addy data (GED patients demoy, Ver Li cally Ne Apacking tem 5 prec pont; sum: dota new; > one tp che witheut +electi on GHGS patients clemey; Tits wi add dam tun; Slosigontally, prec point > stun; , Note: Im arden fo moye with setation oe should have ateasf ye Common ¥Otable. cata new? > one do one uth Ktelation moue patients demog = by ptdl I) Gxt the data firot bom dlatareto dun 5 pec print; sums data neos +» ene b a muerge dal Rics > by famid; > uth elation stun 5 ue Pree print; sun; : ee i aacnt Series prec Sent data = om j/by pid date; sun; Pro ae Sa: ties te tal OCH mess PL el aa Lege) suum data new} —7 vin any Dh amg. cece eae RC 2) by piel dote ; ss mong to laeacea OT should tum hove Atleast 2 fommen VOrjables, data new ; mee ae Cinza) em Cin= b); th F=415% Re win he Complete data fiom "9" and by pid date; somaut chi vag cata ptem b. aan does ne opporte: iba aes ote Sl Cb SRR yaa ~~ Gen data new) mesge ae (in=a) $4 and by by pro date ; Jtum 5 om Cen = bd); takes the Common Ob 304 vation. Enns fon D Conditions Atatements in SAS tf, whore Conclidyenal opetataw Aymbet memonics > gt < dt >= ae <= te u it Logical operators Ayrbel we can wre pice Atep Atatement tn daty Atep and be ured in dak Step Ty Atatement can only dain ALG Aet —-meelf data C where = Ccoenten= 'oppolo COR stun 5 data 42; > Mtecommended Ad mediclata 5 uh ete Cappote), sunt prwe print data= medédata; where >= 25 (RD ge < 40; whee Centet = tappelo’ coh ene centen (ia / ee Lola choneirre) whose Center Gaia Cfoppele?, Savms’) ¢ “un; puec peurt data= mecli data’ wh He ‘cane’ at Center =6rum’) and aaa sige etme psec punt data= meds hata; tah ere Clentey= Seayxe? and age 22k) o1 C Center = 61m? and age 2-25) Stun | 7 proe print data = medidata; multiple hana ews Giheye Hamel ti Re Sy)y, 2 Name Standing unith ¥ wnere name Re ecg names ending ath where mame “Re 'ta7?, > name Containing ve te > maltiple chayacten a, Sing te Chonacter, Murng Date pre punt data = medidate ; where name like © 7 5 fer chonacten yasi atele whee name 49 null; where nome si mining | Where age = 4 > fat numeuc VSatialele where oe =. amd nome “= peach not Fae wh ee age 4s null at name s Tully Eaten pce prumt, sem > data wale female, Act Aadhelpeclan j "4 se = oP? then output female,” Sen = SM? then output male |’ vu! 2 poee peu nt; juny wring hone Afatemend we Cammat CxXente Mew vovunbles, But uring if Statement We Can. data Wale female; set 4arhelp.clars 5 ip Aer= 6? ten gender= “tale ") = “Female”! 2 re sp Aen = SF? Son Goda Cotled tun! ae mew Vaswabde gerdex Ups? then dey = “Male "7 er enting melt ple VOU ables & 8 & & U ard at 5 © arian? ; aS Uheye yy we ae elo we i to use end. The cut put aul hove AU the Votrables as wellar new Variebkr oolded t St, hove pre uiowd S Note taf bene the lengin uae be 4 if we toy to ade again fay jendey = “ Female’ sf Ol cae fone 4 chovact vv Se eam teeta SIR sera amare Sa cca Heeieee eee eee eee eee Eriseseeeeesiseiseeeteres Mme EaasrseseeeE sea SSeEEEE aco] Orta spacer. Simple traiting > @ Oeuble trarling » @ @> Cam rend comecutive obrowvaben don gindes ; ED Acane , Fo score , EN seve mput ID @, input Acere © eS Ouyp uty tmput Acane @, output; ene Wwe uch hove input Acovze Fy output a foto! 4 12 Chen datolines ; Vat; om 111 060 234 WH 62 (oo Hene we are 922252573 8 “4 % Aplitirg the 4 of 2523 59887 3 65 42 43 Voriab tes ard 2058046 Fq 92 95 94 ochre vation, . , stun * Z a Levps jn SAS Do Uhile {$ while me Condition 46 true Do Unk > le the fond; tim ws fahe be Loup. : ep alive lant te do while Lewp wequinem ents: doop variable, Con létion, ince ment | decnement data new; mean alt give al the values ED out ps; | aluay, wre end uit clo Jeun ; Petee point ; Stun; Beamane of inginite loops. Nested Loops dain new, y rete ciae do whi le Cad=4)7 out put > bey: 2 oo uthile C b6<= 5)j od pot 5 b= btij end; Azar; end; Ytun + 4 pwe print, non} Pace Prams pare ¢ Hor om tot to vertical > Nou Norm el? y odion Vor, by Vertical te Hor yontal > Noumall yotion édy Vas, by commider the Gott cusing dataret parmots vertical dala Horu'yontal — Bader pid umitg dorseg pid cart) want 2 fot Wot) Arp - 05mg Io] 5 5 402 uiaiti — A>p-10 mg loz to lo 03 ular Axp- 15mg 103 5 15 toy ian 2. Aap -057q fez wint2 — Hap- lomy 103 amit 2. hop -5 ™q Fs code Converts Vertical dala nto Aoruigental data prec tnam pase = data = mh out = MAL Cup = name); LENCE Variables 1n new otaret var dare; by pid 5 ( cs y > sont Hua fésad- values Hap aye Converted f7do airgte obs Thin code uxt conyett horugoutal data fo verti cal lata proc twams pase = ofeta = mhL out = maz; ven wisitt — viatt2; Vvarvables we want te Comet into by bid * Molues Stun 0 Lets, doR aot anothey enample cata Pod- soles > input pode $ MI-Ms; Conds 1 Hosugental ote Plot = 200 ot 230 234) 0 tBD 280 P02 AD ap Alp OD Bp 2O P103 40 tO kD 210° 220 © 240 , PHec paint: youn) con vend ng Hesigonsal te Vertical proc Aart dada = pro d-4 ako; by Peode; sun) Ptec kta pede data = prod- tales out = Soles 4 5 von mi-me: by peede,’ sium + 2 Conrenting Vertical to Hotino ntal proc -beamspare data = ales! cut = taleo2 * id — name- > art Cott > by peode* sun: prc pint ; stun; pre trampase data= peed medi oul = medi pre gir = wit, td ut? ™ Hee uit isa numescal ay ee wor dove} thin Code Kun +4 wut be a variable. by pid thed Vexjahle names stun; Note ain SAS Cant Atv with a numb .% SAS Witt add en undet- cote, Tp we want te adda Fete Ket we uee She Prefin Afedem ent, New ff We sun she SAS teRea ayerd, Code ui theut mrecersany ee —_a- the thumeuic valued tn the Vat Ateote- Asnays in SAS data Aubj_ bps input subjsidd Abp1- +bpé> Cards > Phot 230 340 710m oO (020 Plo, 310 eon) Cue Sue 50) Plog 20 0 6D 220 ety Pi) OD Bp o 2to 200 tums wf we Aove th seplace the calctard Valuer Hi fn Dome Voli co " & — then " bfetemerd but 4m the above Gor we Witt hove tb site we Con Moe Come in a bt of Atotemento. Array handy in Auch type of rituation, The follouing Cede ts an example, dota new ; ae Aet subj bp; Us we ey ved ables — aoe opplelts bp Abp2 ~Abp2 Abpy Abps A>bpe > do ater es os Fp muning 49 Chowacter we ure * ’ MM able (i) fe them aAbole (i) — 7" 1 the volue uo anaving we mont to impute it with. She pue vious value, the aa cagrton viu be aa follewa elo cet mCi Yoopeleuy =. fen = apple cid = apple Cr-> enol; + obrep c However tf the eros value thse 40 arintng, shen the Code will not atk, «4 ui Show ise Sas Csray, Tf we ont f toke the Pinimum vhlue 4 oll Shooe Valueo, ik opple iy =. then apple ti) = min Cop sbpt - Pbpe)’ New tf we dent knew She tetol HF of You ables along wut th She name 4 the veriiablea we Use the following lode, Lp num etic J anny osete QD Gm aay tole GH) EUEManaeRS ; PD xy character oo i=) to OB Copper, Ty Me data demands we might have to transpose the cloler ond impule Ariana valyer. For ew, we have a Vertiot caf, and we want ft: Condshon- ony impute toy sf Vowt= 10 then Vou2= 20-3 , Ff vols 30 Vanz=60 amd 40 on. fe te axe filling win. t observes one bud avcay wequires vorable. Note that to Convert cboenveclien (ite Vowables we use Feranspere, el wice Veto. Consider the fotouing code, hitn vt2; se vei? Zz ear opple C3) hi Abp Lbp 5 ouwrey bemtpl 3) —temporory_ CF#o l20 60), to 3° "§ opple CO =, then apple ciy= templiy > ucays we have Been ate one—himensisnl Gener ally auugs ate used fo ep lace om ulti ple Vatiables In a atorset. Coney She aaa aed ef 4 2- ol’mensional ret dain new ; see 72 A Ted 72 7S 2 Cands ; ota) BI 3.5 . a dat newt; dimerien' Of orseny variables 1 4 wet mew; EU (2a cece ema en) “7 ae a) ony — OPple C2, 4) 11 -nq ming) — mics 4} eT ees 5a fn datoce '§ oPpte C 2,1) =~ then opplel2,i)=0,;' a St set end, ole ped at dowp iy tuum Rewe Pint; sean Farequency and Men Pouoceduye Impordont Paoe prequemcy by default gives you 4 Atatincics Gs frequency Gi Cum prey, bin petcent — Gw Cum percent perc bee dah = Aashetp. clo; —, give Atafista fer al am; the vot ables buoe preg, cota = 4e> help. chars 5 table 7 eae, cary aac Jium* 4 pre fteq daly = Aodhelp- cla § teble ogee tems 9 Coto tabulation i 7 Stem; Nesting opotan proce preg data= Aadhetp. Clao > table ogew sen | necod {wont Give us Columnuvse stun fe contoge pre pieq data= Aarhetp -clars; table age | out = clan dt > sum; "SS New clatanet wie be created. For thin Atats teal procedure hateset and output will wt loR Emilee . Tn the dataset we alll Bly have count and percentage cumulatives all not be fHerc. we get Cumulotive aud ¢f we ont SHS not fe print every Himes Me jellewing cole uit cook pre freq dats = Aarhetp-etars (ROPUAR, table age | oup = cont (Gamreumy; Hun? 7 pre prey colada = Aarhelp. clan ; tole oge(nocum; > Yio udu mot give cum tum! v Pree pez data = appu; table age! mivaing | 7 Thr aul Give Atetartion well . we cam get cron iabs far ware than tine variables as well. O we Can Aout a Vekiable and uot ng by Atotement. proe preg clata = Aadheltp. clan ji by Aen; table ogc * heiget ot feble ex ¢ age # height; Hum > oufput wit be +ame Proc ce cece n, meam , min, mare, Atel prec mean» data = Aarusey, blood) viun prc means datas aswer. blood; ela gender; -> clavity by gender Van be 5 > ab cuays we a Numeic Varjeble here sum 5 Now tf we cdewt want all te twiahler, then Wwe hove L mention those tHatntin maf oe meed pee mean, data = Aaruret. blood 1 mar min median p25 p75 ; x clan gender; os par condile van tbe ; 75% percentile Sten; Number Fra nat eptiom ly = 150; eee o foc meaw data = Aaruscy. bleed tet, nmins nopsint; Clan gender agegups —? multiple clara? fication van she § (Giunta) oud put = cut = Blood 4) > coreating a new datodet Raa) inact ead of clan we Cam use F Ateofement Uthen we olon't want even Hi ng but Aped fic data only. ie. tohen we ue by ft will only give gou the eton fobufalien port. pc meom datas blood Clan gerd ex bleed gp 5 n mean median,’ Vou webe- oulpet out = bloeod2 n= count Mean = 945 ‘ ~ ; J ene be He nam ed > Ty we cow’ t wont th nome the variables Men we use culput out = bleod2 n= mean = /outo name; prec meam data = bleoel elas genset blood 9p ; ven kbe = Chole § nm mean Me dian neprind, cutput out = blood 2 n(sxbe Chole) = mean (bc) = min (Chole) = [autename ia cea ace Variables fat which we wand to get the Atotiatias. aaa hete one 2 differences between Mean and naa a ond tp Atop +e porting we wute repaint bu) SSRN ee we howe && nije (PRA, fe prec cme data = Blood n mean median prind Gi Ganen we sem PRDRER ustnout ony Atote men it ve TS (RD veniables but (Peay ww jor gle é GEESE Pree Sun” 4 Meomr data= blood "N Mean Median maneec = 2 ree dhe deamoal AW the Atatirtics thet we Con aS N a4 mm eniaring Values MneER = Gl airing voles MEAN SuM MIN Max NEDIAN STD VAR Paoc tebulate,) sd har ubsee Atotements eee clan, var and tube Pree tebulate dada = Aasusen, blood; clan gender ; 2 elemi fi Cation Vorinble Van sebe Panalyris vosucble Columns attem ese) 7 The vowables far which you mort he generate toble fox fable gender; tun; Mere voinhles whith we one wing in table Atedemerd Atould be present either in vor a4 Y we olowt mention elon. ery thing in van by lef oult vi will give You Count. pee tabulate dadq = Aasusen. blood) tam gender bool g up ; toble gender boodgnp tum; > 4 ym den 4 mention omy thing bene 44 Scassaceesae arte Mac ceeeraasHtt cao esa eae MRC nea eeeesaR eeTee MMMESatiT a Sess asSeHeeEEsmeeeRHeEE eS aSSeEE esesSeeE CSS SEES aSeg EEE MEE goer 3 blee kgrorp #1 gendey x bhed pr 4 wl give ou 6% tobuletion Te we ant Curdom Astatisties we hove the following Code, foble Jerden x blood gup y tbe t (min man) chole * Cmeon), oy fable Jendet ¥ blook gp , Ctbe Chole) # (min man); M fetmot = woel Tp we want & PPy the Aame format tr att the velyery proc tabulote data = rasusen. blood foxmoat = 6.0} clan gender — blood guipo ; Vox Abe Chole; table gendeneblodgxp , Cotbe chole)+(minef = 6.2 manrp = 5105 un; Ty we tant Acponate formants (" Aeparate variables we have to mention Like Hud proc tabulate 0 at yender bloodgrps blo gender all*bloodgrp all, (rbe chole)*(min*f=6.2 max*f=5.1) . D> ne man i 1 vorinbles eri Te Rs went give you the “n" Column o oh yo on Pave te p out one ae fives a tread Line J proc report da Lumn Iname sex en er omer ere cee ee eee proc report, data=sashelp.class nowd headskip headlines lunn (2+ name sex age height weight): Jive ete yp poe whee ning te type tem it esl ely ave nyte hy phen not a Line. proc report data-sashelp.class nowd headskip headlines um (* x ant); E jefine name/*nanel Piet 2 > semaming vaptaleles img the vars able, iotine sox/* OR apli ee ae waza proc format ; value $gender 'M'="Male* ‘F*="Fenale'; ae 7 Uudth uded tf smestenre poco report data-sashels nowd headskip plitet; Tum ("nae ex age height weight) the Apace fox whe define sex/width-® format 3 Fei en earn = cen som age hel i ue a ee aluays group the vari able ; Led eM which your gory to a we break. dskip headline split-"*"; qf -> amd ending ” LY puis cow — 0 > over dine Mbetween overtine aml ond edime proc report dat me/"namerof t ter sex/skip ul 4 headskip headline spl ight weight=wtl weig) zee ec Mo “ t 2 Viab , ths Gel Peparately dent tn ee define Aen] acters > een eae am a adekip | Li Gime ulin new variable heqe Senco a ea after > offer seport Compute besarte » befare teput Compute opter — page= 7 offer Poze Begone — pope. P beteye Page ques mgent datensashelp We Can repos the

You might also like