PUT Statement

Accepted Solution Solved
Reply
New Contributor
Posts: 3
Accepted Solution

PUT Statement

Hi everyone.

It's been a while since I used SAS and am wracking my brains for a simple PUT statement.

I have a dataset containing UNIT numbers in the form :

5647               1235               1189

3459               2345               1099

..... more data columns

..... more data columns

I need to read it into SAS, sort it in ascending order and write it back out thus :

1099               1189               1235

2345               3459               5647

I have read it into SAS and sorted it but am struggling with the PUT commands to write it back out

in the format required (3 columns at specific intervals).

I have tried various permutations using OUTPUT and line place holder (@) but no luck.

Can anyone assist please ?

Thanks in advance.


Accepted Solutions
Solution
‎07-10-2013 07:34 AM
New Contributor
Posts: 3

Re: PUT Statement

Amir,

Perfect.

Thank you very much.

Sean.

View solution in original post


All Replies
Super Contributor
Posts: 282

Re: PUT Statement

Posted in reply to crayford_sean

Hi,

Are you looking for something like the following?

data _null_;  

  file <your-file-name>;   

  do i=1 to 3;

    set have; 

    put unit @;

  end;        

  put;        

run;          

Regards,

Amir.

New Contributor
Posts: 3

Re: PUT Statement

Hi Amir,

Thanks alot.

I just need the first value at col02, the 2nd value at col22 and the 3rd value at col42.

Sorry but should've mentioned that before.

Thanks.

Super Contributor
Posts: 282

Re: PUT Statement

Posted in reply to crayford_sean

Hi,

In that case, how about the following:

data _null_;     

  file <your-file-name>;      

  do i=2,22,42;  

    set have;    

    put @i unit @;

  end;           

  put;           

run;             

Regards,

Amir.

Message was edited by: Amir Malik - removed specific file reference.

Solution
‎07-10-2013 07:34 AM
New Contributor
Posts: 3

Re: PUT Statement

Amir,

Perfect.

Thank you very much.

Sean.

Super Contributor
Posts: 644

Re: PUT Statement

OK try

data _null_; 

  set have;

  file <your-file-name>;  

  do i=0 to 2;

     pos = Sum (2, 20*i) ;

    put @pos unit @@;

  end;       

  put;       

run; 


Richard

🔒 This topic is solved and locked.

Need further help from the community? Please ask a new question.

Discussion stats
  • 5 replies
  • 242 views
  • 3 likes
  • 3 in conversation