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 (December 2004, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Thu, 9 Dec 2004 07:37:39 -0500
Reply-To:     Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Jim Groeneveld <jim1stat@YAHOO.CO.UK>
Subject:      Re: Why INPUT function can not change missing values to numeric
              type?
Comments: To: Fred Zhang <ieaggie2002@GMAIL.COM>

Hi Fred,

You can not change the type of a variable. PROC IMPORT apparently yields character variables and these will remain of character type forever. You can, however, read your data file in a normal data step, no PROC IMPORT, forcing numerical variables, applying an INFILE statement and an INPUT statement. Possibly the OPTION MISSING='-' statement also helps to avoid warnings about the '-', but I have no time to test all that. Experiment yourself.

Good luck - Jim. -- Y. (Jim) Groeneveld, MSc., Biostatistician, Science Team Vitatron B.V., Meander 1051, 6825 MJ Arnhem P.O.Box 5227, 6802 EE Arnhem, the Netherlands Tel: +31/0 26 376 7365, Fax: +31/0 26 376 7305 Jim.Groeneveld_AT_Vitatron.com (replace _AT_ by AT sign) http://www.vitatron.com, http://home.hccnet.nl/jim.groeneveld

On Wed, 8 Dec 2004 11:27:05 -0500, Fred <ieaggie2002@GMAIL.COM> wrote:

>Hi, all > >I have a simple type conversion problem as below: >Supose my .txt data set is T1.txt: >ProductID Y99 Y00 Y01 Y02 >abc 10 20 15 - >xyz 25 40 50 - >def 10 30 - - >ghl 2 7 - - >... > >My SAS code is: >PROC IMPORT DATAFILE = 'T1.txt' OUT = T1 > DBMS = TAB REPLACE; >RUN; >DATA External; > SET External; > Y02=INPUT(Y02,BEST10.2); > Y01=INPUT(Y01,BEST10.2); >RUN; >PROC SQL NOPRINT; > SELECT name INTO:num_list separated BY " " > FROM dictionary.columns > WHERE libname="WORK" AND memname="T1" AND type="num"; >Quit; >PROC TRANSPOSE DATA=T1 OUT = T1; > VAR &num_list; > ID ProductID; >RUN; >The LOG window outpus is: >**************** >2316 DATA External; >2317 SET External; >2318 Y02=INPUT(Y02,BEST10.2); >2319 Y01=INPUT(Y01,BEST10.2); >2320 RUN; > >NOTE: Numeric values have been converted to character values at the >places given by: (Line):(Column). > 2318:9 2319:9 >NOTE: Invalid argument to function INPUT at line 2319 column 9. >*************** >And the transposed output table T1 is: >_NAME_ abc xyz def ghl >Y99 10 25 10 2 >Y00 20 40 30 7 > >I do not know why I cannot change the missing values in columns Y01 and Y02 >to be numerical values for my further use. > >Thanks for your correction. > >Fred


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