FUNCTIONS

SAS FUNCTIONS

Get Started. It's Free
or sign up with your email address
Rocket clouds
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. Numeric functions

3.1. int

3.1.1. with out decimal place 34.5=34

3.2. round

3.2.1. rounds nearest integer decimal value 34.54=35

3.3. ceil

3.3.1. round up highest integer value 25.5=26

3.4. floor

3.4.1. rounds up lowest integer value 25.25 = 25

3.5. abs

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

3.6. fact

3.6.1. returns factorials 5 factorial=120

3.7. log

3.7.1. returns loge base vaalues

3.8. lag

3.8.1. get the values from previous variable

3.9. log10

3.9.1. returns log10 values

3.10. mod

3.10.1. returns remainder

4. Character Functions

4.1. SUBSTR

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

4.2. SCAN

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

4.3. COMPRESS

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

4.4. COMPBL

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

4.5. TRIM

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

4.6. STRIP

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

4.7. CATX

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

4.8. TRANWRD

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

4.9. TRANSLATE

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

4.10. INDEX

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

4.11. FIND

4.11.1. SAME AS INDEX

5. Date functions

5.1. DAY

5.2. MONTH

5.3. YEAR

5.4. WEEKDAY

5.5. HOUR

5.6. MINUTE

5.7. SECOND

5.8. DATEPART

5.9. TIMEPART

5.10. DATETIME

5.11. TIME

5.12. DHMS

5.13. HMS

5.14. '20NOV1993'D

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

5.16. TODAY

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