BookmarkSubscribeRSS Feed
Alankar
Fluorite | Level 6
I have data as below.
var
1
1P

3
3F
2
;
i want to exprt this to text file using file statement.
DATA _NULL_;
SET TEST(OBS = 10000);
FILE 'C:\RDIP_1.TXT';
PUT var;
RUN;

output should be with the same data and if there is only one character the second character should be space.
1 (+ 1 spaces)
1P (no spaces)
(2 spaces)
3 (+ 1 spaces)
(2 spaces)
3F (no spaces)
2 (+ 1 spaces)
2 REPLIES 2
chang_y_chung_hotmail_com
Obsidian | Level 7
Use a format when you put. Here is a simple example. Hope this helps.



   /* test dataset */


   data one;


     length var $2;


     do var = "1""1P""""3""3F""2";


       output;


     end;


   run;


 


   /* print out to a text file */


   filename text temp;


   data _null_;


     set one;


     file text;


     put var $2.;


   run;


 


   /* check */


   data _null_;


     infile text;


     input;


     put "***" _infile_ "***";


   run;


   /* on lst


   ***1 ***


   ***1P***


   ***  ***


   ***3 ***


   ***3F***


   ***2 ***


   */


   filename text clear;

deleted_user
Not applicable
hello,

another possible solution is based on file options lrecl and pad added to your statement:

DATA _NULL_;
SET TEST(OBS = 10000);
FILE 'C:\RDIP_1.TXT' lrecl=2 pad;
PUT var;
RUN;

Marius
What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 4806 views
  • 0 likes
  • 3 in conversation