From: breezezhaoeei on 29 Mar 2010 19:49 Hi SAS experts, I tried to change format of one variable from character to numeric? But I tried input and format, it's just won't change. data allevel; set in.posttest; ses=input(isfreeorreduced_n,best1.); grade=input(grade1,best1.); run; Also, data allevel; set in.posttest; ses=isfreeorreduced_n*1; grade=grade1*1; run; I also tried: format ses best1.; format grade best1; It just won't change...... Here's the proc contents result: Alphabetic List of Variables and Attributes # Variable Type Len Format Informat Label 2 grade Char 255 $255. $255. grade 1 schoolid Num 8 schoolid 3 ses Char 255 $255. $255. ses Thanks, Qingfeng
From: Patrick on 30 Mar 2010 06:26 Hi Qingfeng It works for me (see example below). Both variants you've posted should work, IF the variables don't already exist in the input dataset and are defined there as character. You haven't sent the log. I assume this log would show some warnings about character/numeric conversions. HTH Patrick data have; isfreeorreduced_n='1'; var='1'; run; data want; set have(rename=(var=charvar)); ses=input(isfreeorreduced_n,best1.); var=input(charvar,best1.); run; proc contents data=want; run;
From: Barry Schwarz on 30 Mar 2010 21:35 Show us the proc contents of in.posttest. On Mon, 29 Mar 2010 16:49:50 -0700 (PDT), "breezezhaoee> wrote: >Hi SAS experts, > >I tried to change format of one variable from character to numeric? >But I tried input and format, it's just won't change. > >data allevel; >set in.posttest; >ses=input(isfreeorreduced_n,best1.); >grade=input(grade1,best1.); >run; > >Also, >data allevel; >set in.posttest; >ses=isfreeorreduced_n*1; >grade=grade1*1; >run; > >I also tried: >format ses best1.; >format grade best1; > >It just won't change...... >Here's the proc contents result: > > Alphabetic List of Variables >and Attributes > > # Variable Type Len >Format Informat Label > > 2 grade Char 255 >$255. $255. grade > 1 schoolid Num >8 schoolid > 3 ses Char 255 >$255. $255. ses > > >Thanks, >Qingfeng -- Remove del for email
|
Pages: 1 Prev: between-and operator Next: Help Desk Software by PerlDesk |