12K views

Uploaded by SASTechies

Learning
Base SAS,
Advanced SAS,
Proc SQl,
ODS,
SAS in financial industry,
Clinical trials,
SAS Macros,
SAS BI,
SAS on Unix,
SAS on Mainframe,
SAS interview Questions and Answers,
SAS Tips and Techniques,
SAS Resources,
SAS Certification questions...
visit http://sastechies.blogspot.com

save

You are on page 1of 6

com

**Using SAS functions, you SAS function: can function-name(argument-1<
**

◦ 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

,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-toNumeric Conversion

**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,

data hrd.newtemp; set hrd.temp; Salary=payrate*hours; run;

SAS Log

4 5 6 7 data hrd.newtemp; set hrd.temp; Salary=payrate*hours; run;

**Explicit Character-to-Numeric Conversion
**

data hrd.newtemp; set hrd.temp; Salary=input(payrate,2.)*hours; 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.

SAS Techies 2009

11/13/09

Automatic Numeric-toCharacter Conversion

PUT (source,format) where

**data hrd.newtemp; set hrd.temp; Assignment=site||'/'||department; run; SAS Log
**

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.

◦ 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

11/13/09

Functin YEAR MONTH DAY MDY

Description

Form

Sample Value 2002 12 5 01/01/1960 ->> 0

Extracts the year value from a YEAR(date) SAS date value. Extracts the month value from a MONTH(date) SAS date value. Extracts the day value from a SAS date value. Contructs SAS date from the values passed to it

DAY(date)

MDY(month,day,year)

DATE() Today()

Gives the current date

Date() Today()

14686

SAS Techies 2009

11/13/09

Function SCAN SUBSTR

Usage

SCAN(argument,n,delimiters) SUBSTR(argument,position,n)

Example LastName=scan(‘How, R’,1,' ,'); Initial=substr('NsHARAD',1,1); substr(x,1,3)=‘NEW'; Where x=‘SKWEST’

TRIM INDEX

TRIM(argument) LEFT(argument) INDEX(source,excerpt)

NewAddress=trim(‘Jersey ‘) NewAddress=trim(left((‘ Jersey Found=index(‘SAS Analyst,‘SAS ')

‘) )

UPCASE LOWCASE

UPCASE(argument) UPCASE(‘sharad’) LOWCASE(argument) LOWCASE(‘ShaRAD’)

SAS Techies 2009

11/13/09

- SAS Slides 4 : Reading Fixed and Varying DataUploaded bySASTechies
- Learn SAS ProgrammingUploaded bySASTechies
- SAS Slides 6 : ArraysUploaded bySASTechies
- SAS Slides 2 : Basics of SAS Programming LanguageUploaded bySASTechies
- SAS Slides 1 : Introduction to SASUploaded bySASTechies
- SAS Slides 7 : Match Merging with DatastepUploaded bySASTechies
- SAS Slides 12 : MacrosUploaded bySASTechies
- SAS Slides 9 : Plots and GraphsUploaded bySASTechies
- SAS Slides 8 : BASE SAS Statistics ProceduresUploaded bySASTechies
- SAS Slides 10 : ODS HTMLUploaded bySASTechies
- SAS Slides 11 : Utility ProceduresUploaded bySASTechies
- SAS Slides 14 : SAS Access / SAS ConnectUploaded bySASTechies
- SAS Slides 3 : Understanding SAS Data Step ProcessingUploaded bySASTechies
- SAS Interview Questions and Answers 1Uploaded bySASTechies
- SAS Slides 15 : Improving Effeciency With options in SASUploaded bySASTechies
- LEARN SAS within 7 weeks: Part6 (Producing Graphics and Using SAS Analyst)Uploaded bysarath.annapareddy
- SAS TrainingUploaded byharishkode
- SAS Macro That Reads the Filenames Available at a Particular Directory on Any FTP ServerUploaded bySASTechies
- CDISC SDTM BasicsUploaded bysarath.annapareddy
- SAS FundamentalUploaded bysarath.annapareddy
- LEARN SAS within 7 weeks: Part1Uploaded bysarath.annapareddy
- Advanced SAS Programming Techniques (www.studysas.blogspot.com)Uploaded bysarath.annapareddy
- SAS Programming SkillsUploaded bystevensap
- SAS Macro to Fill Missing Values in a Dataset With Specified Values for Numeric and Character ValuesUploaded bySASTechies
- LEARN SAS within 7 weeks: Part5 (Procedures to Summarize Data)Uploaded bysarath.annapareddy
- Base SAS Programming FundamentalsUploaded byクマー ヴィーン
- Carpenter's Complete Guide to SAS MacroUploaded byクマー ヴィーン
- LEARN SAS within 7 weeks: Part4 (More on Manipulating Data)Uploaded bysarath.annapareddy
- LEARN SAS within 7 weeks: Part2 (Introduction to SAS – The Data Step)Uploaded bysarath.annapareddy
- 24599909 Learn SAS ProgrammingUploaded bySheena Thakur

- SAS Macro to Split Dataset by the Number of Observations SpecifiedUploaded bySASTechies
- SAS Macro to Reorder Dataset Variables in Alphabetic OrderUploaded bySASTechies
- SAS Macro That Reads the Filenames Available at a Particular Directory on Any FTP ServerUploaded bySASTechies
- SAS Macro to Create Delete a DirectoryUploaded bySASTechies
- SAS Macro to Fill Missing Values in a Dataset With Specified Values for Numeric and Character ValuesUploaded bySASTechies
- Use SAS Function PropcaseUploaded bySASTechies
- Basic Notes on Clinical Trials Phase I-IVUploaded bySASTechies
- SAS Macro to Split a Macro Variables Values to Multiple Macro Variables Values and Also Get the Split Count Into Another VariableUploaded bySASTechies
- SAS Macro to Create a Delimited Text File From a SAS DatasetUploaded bySASTechies
- SAS Macro to Split a Dataset Into Multiple Datasets Vertically With a Common Primary KeyUploaded bySASTechies
- SAS Macro ExamplesUploaded bySASTechies
- SAS Interview Questions and Answers 1Uploaded bySASTechies
- SAS Slides 7 : Match Merging with DatastepUploaded bySASTechies
- SAS Slides 12 : MacrosUploaded bySASTechies
- SAS Slides 9 : Plots and GraphsUploaded bySASTechies
- SAS Slides 8 : BASE SAS Statistics ProceduresUploaded bySASTechies
- SAS Slides 10 : ODS HTMLUploaded bySASTechies
- SAS Slides 11 : Utility ProceduresUploaded bySASTechies
- SAS Slides 14 : SAS Access / SAS ConnectUploaded bySASTechies
- SAS Slides 3 : Understanding SAS Data Step ProcessingUploaded bySASTechies
- SAS Slides 15 : Improving Effeciency With options in SASUploaded bySASTechies