Date: Tue, 1 Feb 2011 10:57:06 -0800
Reply-To: Karen L <hl2493@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: Karen L <hl2493@YAHOO.COM>
Subject: Re: converting character variable to numeric variable
In-Reply-To: <FA5798D1750F410898E694711B2491E2@D1871RB1>
Content-Type: text/plain; charset=iso-8859-1
Thanks, Nat!
The truth is, with SAS 9.2, there was no problem with the variable name (Reff).
I actually used this code:
proc import datafile='\\data4\users10\klee\raw box\bbb.txt' out=bbb;
Guessingrows=1000;
run;
NOTE: No encoding was specified for the fileref "#LN00240" (for the file
"\\data4\users10\klee\rawbox\bbb.txt"). A byte order mark in the file
indicates that the
data is encoded in "utf-8". This encoding will be used to process the
file.
NOTE: No encoding was specified for the fileref "#LN00241" (for the file
"\\data4\users10\klee\rawbox\bbb.txt"). A byte order mark in the file
indicates that the
data is encoded in "utf-8". This encoding will be used to process the
file.
1221 /**********************************************************************
1222 * PRODUCT: SAS
1223 * VERSION: 9.2
1224 * CREATOR: External File Interface
1225 * DATE: 01FEB11
1226 * DESC: Generated SAS Datastep Code
1227 * TEMPLATE SOURCE: (None Specified.)
1228 ***********************************************************************/
1229 data WORK.BBB ;
1230 %let _EFIERR_ = 0; /* set the ERROR detection macro variable */
1231 infile '\\data4\users10\klee\raw box\bbb.txt' delimiter='09'x MISSOVER
DSD lrecl=32767
1231! firstobs=2 ;
1232 informat Reff $5. ;
1233 informat DateScheduled mmddyy10. ;
1234 informat StartTime time. ;
1235 informat EndTime time. ;
1236 informat Length time. ;
1237 informat hour best32. ;
1238 informat minute best32. ;
1239 informat inmin best32. ;
1240 informat BuffCount best32. ;
1241 informat Theme $77. ;
1242 informat Category $102. ;
1243 informat Subject $148. ;
1244 informat CountryName $86. ;
1245 informat ItemTitle $533. ;
1246 informat Department1 $20. ;
1247 informat ScheduledStatus_ $17. ;
1248 format Reff $5. ;
1249 format DateScheduled mmddyy10. ;
1250 format StartTime time. ;
1251 format EndTime time. ;
1252 format Length time. ;
1253 format hour best12. ;
1254 format minute best12. ;
1255 format inmin best12. ;
1256 format BuffCount best12. ;
1257 format Theme $77. ;
1258 format Category $102. ;
1259 format Subject $148. ;
1260 format CountryName $86. ;
1261 format ItemTitle $533. ;
1262 format Department1 $20. ;
1263 format ScheduledStatus_ $17. ;
1264 input
1265 Reff $
1266 DateScheduled
1267 StartTime
1268 EndTime
1269 Length
1270 hour
1271 minute
1272 inmin
1273 BuffCount
1274 Theme $
1275 Category $
1276 Subject $
1277 CountryName $
1278 ItemTitle $
1279 Department1 $
1280 ScheduledStatus_ $
1281 ;
1282 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection
macro variable */
1283 run;
NOTE: No encoding was specified for the fileref "#LN00242" (for the file
"\\data4\users10\klee\rawbox\bbb.txt"). A byte order mark in the file
indicates that the
data is encoded in "utf-8". This encoding will be used to process the
file.
NOTE: The infile '\\data4\users10\klee\raw box\bbb.txt' is:
Filename=\\data4\users10\klee\raw box\bbb.txt,
RECFM=V,LRECL=196602,File Size (bytes)=124826,
Last Modified=01Feb2011:12:02:48,
Create Time=26Jan2011:12:11:55
NOTE: 619 records were read from the infile '\\data4\users10\klee\raw
box\bbb.txt'.
The minimum record length was 51.
The maximum record length was 542.
NOTE: The data set WORK.BBB has 619 observations and 16 variables.
NOTE: DATA statement used (Total process time):
real time 0.04 seconds
cpu time 0.04 seconds
________________________________
From: Nat Wooding <nathani@verizon.net>
To: Karen L <hl2493@YAHOO.COM>; SAS-L@LISTSERV.UGA.EDU
Sent: Tue, February 1, 2011 12:41:52 PM
Subject: RE: converting character variable to numeric variable
Karen
I suspect that you have missing values for the first 20 or so lines of the
variables that are being read as character so you need to add a
Guessingrows= option to have it look for numbers in more rows. When you
printed the message about Reff not being a valid name, the text that came
through in the email had symbols in front of the R so you may want to
examine the txt file and see whether there names are "clean". You may be
able to do some simple editing and clear up the problem.
Nat Wooding
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of Karen L
Sent: Tuesday, February 01, 2011 12:24 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: converting character variable to numeric variable
Hi guys,
I have a variable called "Reff". This variable includes numbers. (e.g. 1234,
3444, 3334, etc.)
And, I am importing the dataset(txt) into SAS.
This dataset was imported to SAS 9.1 as I expected (reff as numeric
variable)
although SAS couldn't read the variable name correctly.
(Anyways, I received this message:
And then,
I imported the same dataset(txt) to my new server with SAS 9.2.
Interestingly, the same variable (Reff) was imported as character variable.
Firstly, I don't know why this happens. (although the dataset imported to
SAS
successfully. No missing values/overlaps..etc.)
Secondly, I want to convert this Reff(character variable) to numeric
variable.
This code doesn't seem to work:
data bbb1;
infile='\\data\users1\karen\bbb.txt' ;
input reff $4.;
reference=input(reff,comma5.)
run;
Besides, I have over 100 variables in the dataset.. so, I don't think I can
array all the variables in the dataset by using input command.
Do you have any idea how to manage this issue?
Thanks so much!
Karen
"Reff" is not a valid SAS name. )
FYI, this is the code I used:
proc import datafile='\\data\users1\karen\bbb.txt' out=bbb;
run;
With SAS 9.2, I received the following log. Still Reff being character variable.
Can anybody see what went wrong from here?
Thanks,
Karen
|