LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (May 2011, week 4)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Fri, 27 May 2011 09:53:00 -0400
Reply-To:     "Durrett, Cindy" <CindyDurrett@FDLE.STATE.FL.US>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "Durrett, Cindy" <CindyDurrett@FDLE.STATE.FL.US>
Subject:      Re: Delete non-numeric data
In-Reply-To:  <FA0550A1D186FF49BB0748CD711B17EDB2A9426F9B@SDPSMSX.QUALNET.ORG>
Content-Type: text/plain; charset="us-ascii"

Hiakuo wrote: > On a side note, I have noticed that above code failed producing desired > results if I use "LT" instead of ">". I am using SAS 9.2 on windows > workstation. Any ideas?

I see you figured out your LT (less than!) issue, but wanted to say that I have noticed from time to time that using the = does not work and I have to use EQ. I haven't found a pattern but when I know the code is right and it fails and make that switch and it works, then I chalk it up to the gremlin that lives in my PC. (SAS 9.2 on Windows 7 box).

For Bhupinder's question about deleting non-numeric data,

> Data GC2; set GC; > CGR2= CGR2*1; > if CGR2= . then delete; > run;

I would do it this way:

data gc; input cgr2 $2.; CARDS; 1 2 A 3 a 5 3 4 ; run; proc contents data=gc; run; proc print data=gc; run;

DATA GC2 (DROP=WHATEVER); SET GC (RENAME=(CGR2=WHATEVER)); CGR2=WHATEVER+0; *** THIS CONVERTS A CHARACTER FIELD TO NUMERIC AND WILL CREATE MISSING FOR NON-NUMERIC VALUES ***; IF CGR2 = . THEN DELETE; RUN; proc contents data=gc2; run; proc print data=gc2; run;

*** LOG RESULTS ***;

38 data gc; 39 input cgr2 $2.; 40 CARDS;

NOTE: Compression was disabled for data set WORK.GC because compression overhead would increase the size of the data set. NOTE: The data set WORK.GC has 4 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.01 seconds cpu time 0.01 seconds

45 ; 46 run; 47 proc contents data=gc; run;

NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.21 seconds cpu time 0.03 seconds

48 proc print data=gc; run;

NOTE: There were 4 observations read from the data set WORK.GC. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds

49 50 DATA GC2 (DROP=WHATEVER); 51 SET GC (RENAME=(CGR2=WHATEVER)); 52 CGR2=WHATEVER+0; 53 IF CGR2 = . THEN DELETE; 54 RUN;

NOTE: Character values have been converted to numeric values at the places given by: (Line):(Column). 52:6 NOTE: Compression was disabled for data set WORK.GC2 because compression overhead would increase the size of the data set. NOTE: Invalid numeric data, WHATEVER='A' , at line 52 column 6. WHATEVER=A CGR2=. _ERROR_=1 _N_=2 NOTE: Invalid numeric data, WHATEVER='a' , at line 52 column 6. WHATEVER=a CGR2=. _ERROR_=1 _N_=3 NOTE: Missing values were generated as a result of performing an operation on missing values. Each place is given by: (Number of times) at (Line):(Column). 2 at 52:14 NOTE: There were 4 observations read from the data set WORK.GC. NOTE: The data set WORK.GC2 has 2 observations and 1 variables. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.00 seconds

55 proc contents data=gc2; run;

NOTE: PROCEDURE CONTENTS used (Total process time): real time 0.10 seconds cpu time 0.01 seconds

56 proc print data=gc2; run;

NOTE: There were 2 observations read from the data set WORK.GC2. NOTE: PROCEDURE PRINT used (Total process time): real time 0.00 seconds cpu time 0.00 seconds


Back to: Top of message | Previous page | Main SAS-L page