Lecture10 - Concatenation Operator The concatenation...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Concatenation Operator The concatenation operator is another way to join character strings. General form of the concatenation operator: Example: The operator can also be written as two vertical bars (||), or two broken vertical bars (¦¦). NewVar = string1 string2 ; Phone = '('!!area!!') '!!Number; PDV Area $ 3 Number $ 8 Phone $ 14 919 531-0000 (919) 531-0000
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 SAS Help Create a Favorites to the SAS Help entry for Functions by Category.
Background image of page 2
3 Business Scenario Data Clean Up The Internet Sales Group accidentally used the wrong data files for the Orion Star Catalog Web site. They corrected the problem as soon as it was noticed, but some orders were created with data errors in them. orion.clean_up has sample observations showing the problems.
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 Business Scenario Data Clean Up Listing of orion.clean_up Product_ID Product Order_ID 21 02 002 00003 Sunfit Trunks, Blue 1231986335 21 02 002 00003 Luci Knit Mittens, Red 1232003930 21 02 002 00004 Luci Knit mittens, Blue 1232007693 21 02 002 00004 1232007700 21 02 002 00005 Sunfit Trunks, Yellow 1232087464 21 02 002 00005 Lucky Knit Mittens, Black 1232092527 The Product_ID for mittens should have 005 instead of a 002 for the third group of numbers. Luci is a typo; the correct word is Lucky. Product_ID values should have no internal spaces. All words in the Product value should start with a capital letter.
Background image of page 4
5 Business Scenario Desired Output The correct data set shows what the data should be. Listing of correct Product_ID Product Order_ID 210200200003 Sunfit Trunks, Blue 1231986335 210200500003 Lucky Knit Mittens, Red 1232003930 210200500004 Lucky Knit Mittens, Blue 1232007693 210200200004 Sunfit Trunks, Aqua 1232007700 210200200005 Sunfit Trunks, Yellow 1232087464 210200500005 Lucky Knit Mittens, Black 1232092527
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 Data Clean Up Step 1 The first step in creating the correct data set is to do the following: Find the observations with Mittens as part of the Product value. Change the middle characters of the Product_ID values for those observations. The FIND and SUBSTR functions will be useful for this.
Background image of page 6
7 The FIND Function The FIND function searches a target string for a specified substring. General form of the FIND function: The FIND function returns a numeric value that is the starting position of the first occurrence of substring within string , if substring is found 0, if substring is not found. Position = FIND( string,substring<,modifiers,startpos> ); continued. ..
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
8 The FIND Function The FIND function searches a target string for a specified substring . General form of the FIND function: Modifiers can be I to indicate a case-insensitive search T to indicate to ignore trailing blanks in the string and substring values. startpos indicates where in the string to start searching for the substring . Position = FIND( string,substring<,modifiers,startpos> );
Background image of page 8
9 The FIND Function Example What value will SAS assign to Pos1 ? data find; Text='AUSTRALIA, DENMARK, US'; Pos1=find(Text,'US'); Pos2=find(Text,' US'); Pos3=find(Text,'us'); Pos4=find(Text,'us','I'); Pos5=find(Text,'us','I',10); run; PDV Pos1 N 8
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
10 The FIND Function Example ...
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 169

Lecture10 - Concatenation Operator The concatenation...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online