FUNCTIONS

SAS FUNCTIONS

Get Started. It's Free
or sign up with your email address
FUNCTIONS by Mind Map: FUNCTIONS

1. data c; date=today(); dt=datetime(); time=time(); dt2=dhms(date,8,10,22); time2=hms(8,13,14); dob='20nov1993'd; age=int(yrdif(dob,date,'actual')); format date dob date9. dt dt2 datetime. time time2 time.; run;

2. data f; input date : date9. time : time8. datetime: datetime.; format date date9. time time8. datetime datetime.; cards; 20nov1993 10:23:24 27jun2019:04:41:23 03dec1992 11:23:25 28jun2019:12:13:20 ; run; options ls=200; data g; set f; day=day(date); month=month(date); year=year(date); wkd=weekday(date); hour=hour(time); minute=minute(time); sec=second(time); dprt=datepart(datetime); timeprt=timepart(datetime); format dprt date9. timeprt timeampm10. ; run;

3. Date functions

3.1. DAY

3.2. MONTH

3.3. YEAR

3.4. WEEKDAY

3.5. HOUR

3.6. MINUTE

3.7. SECOND

3.8. DATEPART

3.9. TIMEPART

3.10. DATETIME

3.11. TIME

3.12. DHMS

3.13. HMS

3.14. '20NOV1993'D

3.15. INT(DOB,DATE,'ACTUAL')

3.16. TODAY

3.17. INTCK(DAYS/YEARS/MONTH,BDAY,SVDATE)

4. Numeric functions

4.1. int

4.1.1. with out decimal place 34.5=34

4.2. round

4.2.1. rounds nearest integer decimal value 34.54=35

4.3. ceil

4.3.1. round up highest integer value 25.5=26

4.4. floor

4.4.1. rounds up lowest integer value 25.25 = 25

4.5. abs

4.5.1. absolute value convert +ve to -ve & -ve to +ve

4.6. fact

4.6.1. returns factorials 5 factorial=120

4.7. log

4.7.1. returns loge base vaalues

4.8. lag

4.8.1. get the values from previous variable

4.9. log10

4.9.1. returns log10 values

4.10. mod

4.10.1. returns remainder

5. Character Functions

5.1. SUBSTR

5.1.1. data fd; x='i will stir and bash up'; y=substr(x,8,4); run;

5.2. SCAN

5.2.1. data ff; x='i -will - stir - and - bash up'; y=scan(x,3,'-'); run;

5.3. COMPRESS

5.3.1. data fg; x='i will stir and bash up'; y=compress(x,'iab'); run;

5.4. COMPBL

5.4.1. data fh; x='i will stir and bash up'; y=compbl(x); run;

5.5. TRIM

5.5.1. data fj; x='this '; y='is'; z='gowtham'; new=trim(x)||' '||y||' '||z; run;

5.6. STRIP

5.6.1. data fl; x='this '; y=' is'; z='gowtham'; new=trim(x)||' '||strip(y)||' '||z; run;

5.7. CATX

5.7.1. data fq; w='this '; x=' is'; y=' gorantla '; z=' gowtham '; new=catx(' ',w,x,y,z); run;

5.8. TRANWRD

5.8.1. data ft; x='this is gowtham gorantla'; y=tranwrd(x,'gowtham','govinda'); run;

5.9. TRANSLATE

5.9.1. data fw; x='this is gowtham gorantla'; y=translate(x,'hs','go'); run;

5.10. INDEX

5.10.1. data fz; name='this is gorantla gowtham'; INDEX=index(name,'s'); INDEXC=indexc(name,'is'); INDEXW=indexw(name,'is '); run;

5.11. FIND

5.11.1. SAME AS INDEX