Discussion:
export dat file from SAS
(too old to reply)
zenny
2007-06-12 10:15:54 UTC
Permalink
Hi guys,

I want to export sas dataset to a txt file. The code is:

data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8
value2 9-16
value3 17-24
;
run;

this is fine to get the dat file, however, I want to keep two decimals
of each variable and the whole length is 8. should it be like this?

data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8.2
value2 9-16.2
value3 17-24.2
;
run;

it doesn't work. How should I write the code?

Thanks,
Zenny
a***@bigfoot.com
2007-06-12 13:05:21 UTC
Permalink
put (value1 - value3) (8.2);
Post by zenny
Hi guys,
data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8
value2 9-16
value3 17-24
;
run;
this is fine to get the dat file, however, I want to keep two decimals
of each variable and the whole length is 8. should it be like this?
data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8.2
value2 9-16.2
value3 17-24.2
;
run;
it doesn't work. How should I write the code?
Thanks,
Zenny
Howard Schreier <hs AT dc-sug DOT org>
2007-06-13 13:27:40 UTC
Permalink
Post by zenny
Hi guys,
data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8
value2 9-16
value3 17-24
;
run;
this is fine to get the dat file, however, I want to keep two decimals
of each variable and the whole length is 8. should it be like this?
data _null_;
set sc_dat;
file 'c:\temp\sc.dat' DSD;
put
value1 1-8.2
value2 9-16.2
value3 17-24.2
;
run;
No; you can't just make up your own syntax.
Post by zenny
it doesn't work. How should I write the code?
As far as I know, you have to abandon column-style output and instead use
formatted output with pointer controls (though your example is so simple
that default pointer behavior would do).

put @ 1 value1 8.2
@ 9 value2 8.2
@ 17 value3 8.2 ;

By the way, the DSD option pertains to list output and does not have any
effect here.
Post by zenny
Thanks,
Zenny
Continue reading on narkive:
Search results for 'export dat file from SAS' (Questions and Answers)
3
replies
How to I add an iMovie file to DVD?
started 2010-10-14 17:00:44 UTC
software
Loading...