Post by HariHi,
When I look up the log for Proc Export for my above problem then I get
the following (I changed only the variable names and the number of
variables. Also , I dont want to write out the variable names in my
outfile so removed that loop. Othe than these changes I have not
tampered with the code below.)
data _null_;
set &FinalHBRegData end=EFIEOD;
%let _EFIERR_ = 0; /* set the ERROR detection macro variable */
%let _EFIREC_ = 0; /* clear export record count macro variable
*/
file '&ProjectRootFolderPath.\Working\Exported files\2006 01
30\&FinalHBRegData..csv'
delimiter=',' DSD DROPOVER lrecl=32767;
format InterCeptDumm best12. ;
format IndepVar1 best12. ;
format IndepVar2 best12. ;
format IndepVar3 best12. ;
format IndepVar4 best12. ;
format DepenVar best12. ;
do;
EFIOUT + 1;
;
end;
if _ERROR_ then call symputx('_EFIERR_',1); /* set ERROR detection
macro variable */
if EFIEOD then call symputx('_EFIREC_',EFIOUT);
run;
I want to store the write-out format for my numeric variables
(IndepVar1 to DepenVar with number of decimal places as 2. I dont know
how to control that. The widths of different numeric variables are
quite different for example, InterceptDumm (Stands for value of
Intercept which is always 1) has width as 1 and the IndepVar1/IndepVar2
has maximum of value 9999 and number of decimal places varying from one
row to another (as seen from data file view). Similarly other 3
variables IndepVar3, IndepVar4 and DepenVar hav maximum values as lets
say a six digit number. In short how do I customize my above variables
to have
Also, the PUT statement in Log of Proc Export shows that it is writing
can understand such kind of problems happening in case of Proc Import
but why should it happen while exporting?
Just to add am facing one more problem. When I try to read in numerical
data from output of another software then SAS is reading it as String
(My first 20 rows of that variable is missing). K , I can probably
overcome this by using the Log of Proc Import, but am concerned that
even when I dont have string data in any of my variables (string used
to get truncated while using Proc Import), then am forced to use the
Log of proc Import.
Regards,
Hari
India
Use proc import when you know little about the data.
When you know the structure (data types), just use a
DATA step. It is really simple for anything that a basic
proc import might be able to handle.
data <output table name> ;
length /* define all columns on the input, whether
numeric or character, with their (output) lengths,
and in the order of the input columns */
;
informat /*define columns needing informats, like yymmdd10.
;
infile /* define input file, including
lrecl= if >256
DSD when handling delimited data
dlm= if delimiter is not comma */
;
input <firstvariable> -- <lastvariable> ;
run;
Reading a csv file should be that simple.
When writing out data, it may be effective to adopt a similar
policy when anything other than default style is needed.
data _null_ ;
file /*define the required output data file with
DSD for delimited text output
lrecl= when >256
dlm= provide the delimiter when other than comma
***********************/
;
put 'column,header,as,you,choose' ;
/*can be more complex, but ... why ? */
do until( end_of_input );
set /* define the input data set(s) */
end= end_of_input ;
;
/* where subsetting if neccessary ; ***/
put ( list of columns to extract )(:) ;
end;
/*
put a trailer record to indicate end-of-file if required*/
stop ;
run;
Good Luck
Peter Crawford