| Date: | Thu, 3 Nov 2011 20:24:00 -0400 |
| Reply-To: | Venky Chakravarthy <sasyellvenky@GMAIL.COM> |
| Sender: | "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU> |
| From: | Venky Chakravarthy <sasyellvenky@GMAIL.COM> |
| Subject: | Re: Special Characters |
|
| In-Reply-To: | <CAGeEwWE0+U7ntJRWoOett-C_NPdFcESHk3DmC37J3iJfhjagew@mail.gmail.com> |
| Content-Type: | text/plain; charset=UTF-8 |
After seeing Andre's response, there is a better understanding of the
problem. I don't know enough about using the UNICODE function but it
seems to convert Unicode characters to the numeric encoding in the
current SAS session. There must be an additional step that I am
missing with that solution.
Further clarification of the problem will help. You will need to
define what is acceptable as values.
1. Numbers
2. Alphabets
3. You may want to visit http://www.asciitable.com/ and see the range
of acceptable values in your variables. You may then try something
like the following where __n1 corresponds to a flag for var1, __n2 for
var2 and so on. A positive value indicates the presence of
non-acceptable characters:
** define a space, a left and a right paren as compress characters ** ;
** adjust accordingly - using asciitable.com ** ;
%let compchar=( ) ;
data want ;
set have end = eof ;
array __c (*) $ _character_ ;
array __n (3) ;
do _n_ = 1 to dim(__c) ;
__n(_n_) = notalnum(compress(strip(__c(_n_)),"&compchar")) ;
end ;
run ;
options nocenter ;
proc print ;
run ;
Venky Chakravarthy
On Thu, Nov 3, 2011 at 5:08 PM, Venky Chakravarthy
<sasyellvenky@gmail.com> wrote:
> Have you tried using the ANYCNTRL function.
>
> http://support.sas.com/documentation/cdl/en/lefunctionsref/63354/HTML/default/viewer.htm#p1mt339n2zhb33n1uejmw7470orv.htm
>
> Venky Chakravarthy
>
> On Thu, Nov 3, 2011 at 4:41 PM, Singh <adsingh78@gmail.com> wrote:
>> Hi,
>>
>> Is there a way to output only those observations and only those variables
>> in a SAS dataset that have special characters?
>>
>> HAVE:
>>
>> id(N) var1(C) var2(C) var3(C)
>> 101 Klean-Prepā„¢ diabetes Nutritional Supplement
>> 102 lanzor Health Suppelment lidocaĆÆne
>> 103 L-Tyrox 50 µg fish oil supplement lopéramide (Imodium)
>>
>> WANT:
>>
>> id(N) var1(C) var3(C)
>> 101 Klean-Prepā„¢ Nutritional Supplement
>> 102 lanzor lidocaĆÆne
>> 103 L-Tyrox 50 µg lopéramide (Imodium)
>>
>> I am using the following code, but this does not work as I get error
>> message:
>> ERROR: Some character data was lost during transcoding in the dataset
>>
>> data want;
>> set have;
>> if compress(lowcase(var1),'abcdefghijklmnopqrstuvwxyz') eq '' then
>> delete;
>> run;
>>
>>
>>
>> Thanks in advance!!
>>
>
|