You may want to remove certain characters from a string (such as blanks) before you test, process, or store the string in a data set. A very useful function, COMPRESS, makes this job almost trivial.To demonstrate blank removal,suppose that you want to merge two files, keying on last names.Unfortunately, the data entry clerks were not consistent in their use of blanks. For example, you might have 'Mc Lauglin' in one file and 'McLauglin' in the other.Create a new MASTER file by removing all blanks from the variable LASTNAME.
The first argument of the COMPRESS function is the variable to operate on.The second argument contains the characters to be compressed out of the string. Using the COMPRESS function with only a single argument removes all blanks (the default compressable character) from the first argument.If you want to remove characters other than blanks, you place all characters to be removed as the second argument in quotes. For example to remove parentheses, dashes,and blanks from telephone numbers you would write:TELEPHON=COMPRESS (TELEPHON,' ()-');
If you like to live mildly dangerously, you could modify the values of LASTNAME in the original data set (MASTER) without having to create a new data set. By using the same data set name on the DATA and SET statements, you can accomplish this somewhat risky operation:DATA MASTER;
Remember that recovery from such a program may be difficult or impossible.A related function, COMPBL,converts occurrences of multiple contiguous blanks into single blanks.If a variable ADDRESS contained the value '123 SESAME ST.KIDSTOWN, NY 10101', the code COMPBL (ADDRESS); would yield, '123 SESAME ST. KIDSTOWN, NY 10101' with one blank between each set of non-blank characters.
SAS Programming Related Tutorials
|SASS (Syntactically Awesome Style sheets) Tutorial||R Programming language Tutorial|
SAS Programming Related Interview Questions
|Logistics Interview Questions||SAS Programming,SQL server Interview Questions|
|Clinical SAS Interview Questions||SASS (Syntactically Awesome Style sheets) Interview Questions|
|SQL Server Analysis Services (SSAS) Interview Questions||R Programming language Interview Questions|
|SAS DI Interview Questions||Advanced SAS Interview Questions|
|Base Sas Interview Questions||SAS Macro Interview Questions|
|Clinical Data Management Interview Questions|
Sas Programming Tutorial
Input And Infile
Set, Merge, And Update
Table Lookup Tools
Proc Means And Proc Uimivariate
All rights reserved © 2018 Wisdom IT Services India Pvt. Ltd
Wisdomjobs.com is one of the best job search sites in India.