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 (January 2006, week 2)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Sat, 14 Jan 2006 11:25:19 -0500
Reply-To:     Arthur Tabachneck <art297@NETSCAPE.NET>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         Arthur Tabachneck <art297@NETSCAPE.NET>
Subject:      Re: String Values getting truncated in Proc export of CSV
Comments: To: Hari Prasadh <excel_hari@YAHOO.COM>

Hari,

If you are converting the log (from, say, proc import), you can establish the desired variable names directly in your code. You indicated changing the name on an informat statement, but since proc import would have created format and input statements as well you will have to change the names for all three statements.

You indicated that the file already has names in the first row but, if you look at the log, proc import assigned the names to informat, format and input statements and actually begins reading the file at line 2.

My guess is that you aren't gaining anything by turning the code into a macro, as you can always save it and simply include it where desired, but I admitedly don't know all of the circumstances that may be involved.

Art ------------ On Sat, 14 Jan 2006 03:06:12 -0800, Hari <excel_hari@YAHOO.COM> wrote:

>Arthur, > >I have one clarification while using code from SAS log for raw data >read. My raw file already has variable names in the first line of the >data file. > >I dont like the names of those variables and it doesnt jell with the >kind of variable names (or because of possible conflict with names of >variables from other file) I like to rename the variables. > >Following is the partial log for Proc Export > >401 pROC IMPORT OUT= RawSASFileName >402 DATAFILE= "C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv" >403 DBMS=CSV REPLACE; >404 GETNAMES=YES; >405 DATAROW=2; >406 RUN; > ><snip> > >412 * DESC: Generated SAS Datastep Code >413 * TEMPLATE SOURCE: (None Specified.) >414 >***********************************************************************/ >415 data RawSASFileName ; >416 %let _EFIERR_ = 0; /* set the ERROR detection macro variable >*/ >417 infile 'C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv' delimiter = >417! ',' MISSOVER DSD lrecl=32767 firstobs=2 ; >418 informat JOIL_MKT $6. ; >419 informat QUACK_ID $7. ; >420 informat W_E_DATE"," mmddyy10. ; > ><snipped some part> > >430 informat U_POI best32. ; >431 format JOIL_MKT $6. ; >432 format QUACK_ID $7. ; >433 format W_E_DATE mmddyy10. ; > >< snipped again> > >443 format U_POI best12. ; >444 input >445 JOIL_MKT $ >446 QUACK_ID $ >447 W_E_DATE ><snipped again> >457 U_POI >458 ; >459 if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR >detection macro variable >459! */ >460 run; > >NOTE: The infile 'C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv' is: > File Name=C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv' , > RECFM=V,LRECL=32767 > >NOTE: 2264 records were read from the infile C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv'. > The minimum record length was 62. > The maximum record length was 96. >NOTE: The data set FACTORM.RAWSASFILENAME has 2264 observations and 13 >variables. > >I took the code above and converted it in to a macro so that I can read >lots of different files having the same structure. Before doing that I >did 2 things:- > >a) Changed the length of JOIL_MKT variable to 22 (my maximum is 20, but >I just put 22) > >Just doing part a) my code works fine and is able to read > >b) Second, I tried to rename the variable Joil_MKT to something else >like "Client_MKT" and the variable "W_E_DATE" to >"ClientWeekdate" like > >413 * TEMPLATE SOURCE: (None Specified.) >414 >***********************************************************************/ >415 data RawSASFileName ; >416 %let _EFIERR_ = 0; /* set the ERROR detection macro variable >*/ >417 infile 'C:\Documents and >Settings\abc\Desktop\Temp\RawCSVfile_Y.csv' delimiter = >417! ',' MISSOVER DSD lrecl=32767 firstobs=2 ; >418 informat Client _MKT $6. ; >419 informat QUACK_ID $7. ; >420 informat ClientWeekdate "," mmddyy10. ; > >But it doesnt rename the variable. > >I want to know as to whether it is possible to rename the variable >while reading the data from an extrenal file itself? > >Regards, >Hari >India


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