SlideShare a Scribd company logo
2
Most read
4
Most read
6
Most read
SASTechies [email_address] http://www.sastechies.com
Using SAS functions, you can convert data from one data type to another.  calculate sample statistics  create SAS date values  convert ZIP codes to state postal codes  round values  generate random numbers  extract a portion of a character value  SAS function: function-name (argument-1< ,argument-n>) ;  where  argument  can be  variables  mean( x,y,z )  constants  mean( 502,612,498 )  expressions   mean(37*2,192/5, mean(22,34,56) )  Even if the function does not require arguments, the function name must still be followed by parentheses, for example:  function-name (). SAS Techies  2009 11/13/09
Automatic Character-to-Numeric Conversion   data hrd.newtemp;  set hrd.temp; Salary=payrate*hours; run;  INPUT ( source,informat ) where  source  indicates the character variable, constant, or expression to be converted to a numeric value  a numeric informat must also be specified,  Explicit Character-to-Numeric Conversion data hrd.newtemp; set hrd.temp; Salary=input(payrate,2.)*hours;  run;  SAS Techies  2009 SAS Log  11/13/09 4 data hrd.newtemp;  5 set hrd.temp;  6 Salary=payrate*hours; 7 run;  NOTE: Character values have been converted to numeric   values at the places given by: (Line):(Column).   6:11   NOTE: The data set Hrd.Newtemp has 40 observations and 19 variables.  NOTE: The data statement used 0.78 seconds.
Automatic Numeric-to- Character Conversion PUT  ( source,format ) where  source  indicates the numeric variable, constant, or expression to be converted to a character value  a  format  matching the data type of the source must also be specified Explicit Numeric-to- Character Conversion data hrd.newtemp;  set hrd.temp; Assi= put(site,2.) ||'/'||department;  run;  SAS Techies  2009 SAS Log  data hrd.newtemp;  set hrd.temp;  Assignment=site||'/'||department;  run;  11/13/09 4 data hrd.newtemp;  5 set hrd.temp; 6 SiteCode=site||department; 7 run;  ---> NOTE: Numeric values have been converted   to character values at the   places given by: (Line):(Column).   11:13 NOTE: The data set Hrd.Newtemp has 40 observations and 19 variables.  NOTE: The data statement used 1.06 seconds.
SAS Techies  2009 11/13/09 DATE() Today() Gives the current date Date() Today()   14686 MDY Contructs SAS date from the values passed to it MDY( month,day,year )   01/01/1960 ->> 0 Functin Description Form Sample Value YEAR Extracts the year value from a SAS date value. YEAR( date ) 2002   MONTH Extracts the month value from a SAS date value. MONTH( date ) 12   DAY Extracts the day value from a SAS date value. DAY( date ) 5
SAS Techies  2009 11/13/09 Example LastName=scan(‘How, R’,1,' ,');   Initial=substr('NsHARAD',1,1); substr(x,1,3)=‘NEW';  Where x=‘SKWEST’ NewAddress= trim(‘Jersey  ‘)   NewAddress= trim(left((‘  Jersey  ‘) ) Found=index(‘SAS Analyst,‘SAS ')  UPCASE(‘sharad’) LOWCASE(‘ShaRAD’) Function Usage SCAN SCAN( argument,n,delimiters )   SUBSTR SUBSTR( argument,position,n )   TRIM TRIM( argument )   LEFT (argument) INDEX INDEX( source,excerpt )   UPCASE UPCASE( argument )   LOWCASE LOWCASE( argument )

More Related Content

PPT
Base SAS Statistics Procedures
PPT
SAS Macros
PPT
SAS Macros part 1
PDF
Sas cheat
PDF
SAS cheat sheet
PPT
Data Match Merging in SAS
PPTX
Proc SQL in SAS Enterprise Guide 4.3
PPT
Basics Of SAS Programming Language
Base SAS Statistics Procedures
SAS Macros
SAS Macros part 1
Sas cheat
SAS cheat sheet
Data Match Merging in SAS
Proc SQL in SAS Enterprise Guide 4.3
Basics Of SAS Programming Language

What's hot (20)

PPT
Understanding SAS Data Step Processing
PPT
Utility Procedures in SAS
PPT
INTRODUCTION TO SAS
PPTX
SAS Macro
PDF
Introduction to SAS Data Set Options
DOCX
Base sas interview questions
PDF
Introduction To Sas
PPT
SAS BASICS
ODP
PDF
Basics of SAS
PPT
Visualizing Proc Transpose
DOCX
SAS Programming Notes
PPT
SAS Access / SAS Connect
PDF
Proc report
PDF
Introduction to sas
PPT
SAS Macros part 2
DOCX
Sas practice programs
PPTX
SAS basics Step by step learning
PPT
Sas Plots Graphs
Understanding SAS Data Step Processing
Utility Procedures in SAS
INTRODUCTION TO SAS
SAS Macro
Introduction to SAS Data Set Options
Base sas interview questions
Introduction To Sas
SAS BASICS
Basics of SAS
Visualizing Proc Transpose
SAS Programming Notes
SAS Access / SAS Connect
Proc report
Introduction to sas
SAS Macros part 2
Sas practice programs
SAS basics Step by step learning
Sas Plots Graphs
Ad

Viewers also liked (10)

PPT
Improving Effeciency with Options in SAS
PPT
Arrays in SAS
PPT
SAS ODS HTML
PPT
SAS Proc SQL
PPT
Reading Fixed And Varying Data
PDF
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
PPSX
SAS TRAINING
DOCX
Sas Macro Examples
DOCX
Learn SAS Programming
PDF
Base SAS Exam Questions
Improving Effeciency with Options in SAS
Arrays in SAS
SAS ODS HTML
SAS Proc SQL
Reading Fixed And Varying Data
Learning SAS by Example -A Programmer’s Guide by Ron CodySolution
SAS TRAINING
Sas Macro Examples
Learn SAS Programming
Base SAS Exam Questions
Ad

Similar to SAS Functions (20)

PPTX
SAS functions.pptx
PPT
PPT
Prog1 chap1 and chap 2
PPT
Les03 (Using Single Row Functions To Customize Output)
PDF
SAS Internal Training
PPT
PPT
e computer notes - Single row functions
PPT
Intro to tsql unit 10
PPT
Save Coding Time with Proc SQL.ppt
PPT
PPTX
Business Intelligence Portfolio
PPT
Oracle tips and tricks
PDF
Data Exploration with Apache Drill: Day 2
PPT
Dat402
PPT
Advanced dot net
PDF
Pumps, Compressors and Turbine Fault Frequency Analysis
PDF
Interactive Session on Sparkling Water
PDF
DP080_Lecture_2 SQL related document.pdf
DOCX
Pumps, Compressors and Turbine Fault Frequency Analysis
SAS functions.pptx
Prog1 chap1 and chap 2
Les03 (Using Single Row Functions To Customize Output)
SAS Internal Training
e computer notes - Single row functions
Intro to tsql unit 10
Save Coding Time with Proc SQL.ppt
Business Intelligence Portfolio
Oracle tips and tricks
Data Exploration with Apache Drill: Day 2
Dat402
Advanced dot net
Pumps, Compressors and Turbine Fault Frequency Analysis
Interactive Session on Sparkling Water
DP080_Lecture_2 SQL related document.pdf
Pumps, Compressors and Turbine Fault Frequency Analysis

Recently uploaded (20)

PPT
“AI and Expert System Decision Support & Business Intelligence Systems”
PPTX
Big Data Technologies - Introduction.pptx
PDF
Machine learning based COVID-19 study performance prediction
PPTX
Spectroscopy.pptx food analysis technology
PDF
Spectral efficient network and resource selection model in 5G networks
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Encapsulation_ Review paper, used for researhc scholars
PPTX
Understanding_Digital_Forensics_Presentation.pptx
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Approach and Philosophy of On baking technology
PDF
Network Security Unit 5.pdf for BCA BBA.
PPT
Teaching material agriculture food technology
“AI and Expert System Decision Support & Business Intelligence Systems”
Big Data Technologies - Introduction.pptx
Machine learning based COVID-19 study performance prediction
Spectroscopy.pptx food analysis technology
Spectral efficient network and resource selection model in 5G networks
Per capita expenditure prediction using model stacking based on satellite ima...
Mobile App Security Testing_ A Comprehensive Guide.pdf
Encapsulation_ Review paper, used for researhc scholars
Understanding_Digital_Forensics_Presentation.pptx
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Unlocking AI with Model Context Protocol (MCP)
ACSFv1EN-58255 AWS Academy Cloud Security Foundations.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Diabetes mellitus diagnosis method based random forest with bat algorithm
Dropbox Q2 2025 Financial Results & Investor Presentation
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Approach and Philosophy of On baking technology
Network Security Unit 5.pdf for BCA BBA.
Teaching material agriculture food technology

SAS Functions

  • 2. Using SAS functions, you can convert data from one data type to another. calculate sample statistics create SAS date values convert ZIP codes to state postal codes round values generate random numbers extract a portion of a character value SAS function: function-name (argument-1< ,argument-n>) ; where argument can be variables  mean( x,y,z ) constants  mean( 502,612,498 ) expressions   mean(37*2,192/5, mean(22,34,56) ) Even if the function does not require arguments, the function name must still be followed by parentheses, for example: function-name (). SAS Techies 2009 11/13/09
  • 3. Automatic Character-to-Numeric Conversion data hrd.newtemp; set hrd.temp; Salary=payrate*hours; run; INPUT ( source,informat ) where source indicates the character variable, constant, or expression to be converted to a numeric value a numeric informat must also be specified, Explicit Character-to-Numeric Conversion data hrd.newtemp; set hrd.temp; Salary=input(payrate,2.)*hours; run; SAS Techies 2009 SAS Log 11/13/09 4 data hrd.newtemp; 5 set hrd.temp; 6 Salary=payrate*hours; 7 run; NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 6:11 NOTE: The data set Hrd.Newtemp has 40 observations and 19 variables. NOTE: The data statement used 0.78 seconds.
  • 4. Automatic Numeric-to- Character Conversion PUT ( source,format ) where source indicates the numeric variable, constant, or expression to be converted to a character value a format matching the data type of the source must also be specified Explicit Numeric-to- Character Conversion data hrd.newtemp; set hrd.temp; Assi= put(site,2.) ||'/'||department; run; SAS Techies 2009 SAS Log data hrd.newtemp; set hrd.temp; Assignment=site||'/'||department; run; 11/13/09 4 data hrd.newtemp; 5 set hrd.temp; 6 SiteCode=site||department; 7 run; ---> NOTE: Numeric values have been converted to character values at the places given by: (Line):(Column). 11:13 NOTE: The data set Hrd.Newtemp has 40 observations and 19 variables. NOTE: The data statement used 1.06 seconds.
  • 5. SAS Techies 2009 11/13/09 DATE() Today() Gives the current date Date() Today() 14686 MDY Contructs SAS date from the values passed to it MDY( month,day,year ) 01/01/1960 ->> 0 Functin Description Form Sample Value YEAR Extracts the year value from a SAS date value. YEAR( date ) 2002 MONTH Extracts the month value from a SAS date value. MONTH( date ) 12 DAY Extracts the day value from a SAS date value. DAY( date ) 5
  • 6. SAS Techies 2009 11/13/09 Example LastName=scan(‘How, R’,1,' ,'); Initial=substr('NsHARAD',1,1); substr(x,1,3)=‘NEW'; Where x=‘SKWEST’ NewAddress= trim(‘Jersey ‘) NewAddress= trim(left((‘ Jersey ‘) ) Found=index(‘SAS Analyst,‘SAS ') UPCASE(‘sharad’) LOWCASE(‘ShaRAD’) Function Usage SCAN SCAN( argument,n,delimiters ) SUBSTR SUBSTR( argument,position,n ) TRIM TRIM( argument ) LEFT (argument) INDEX INDEX( source,excerpt ) UPCASE UPCASE( argument ) LOWCASE LOWCASE( argument )

Editor's Notes

  • #3: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #4: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #5: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #6: SASTechies.com Sharad C Narnindi - Attic Technologies 2005
  • #7: SASTechies.com Sharad C Narnindi - Attic Technologies 2005