data want;
attrib
_inline_ length = $ 32767
Quarter label = 'Quarter'
length = 8 informat = yyq6. format = yyq6.
Product_Group label = 'Product Group'
length = $ 24 informat = $24. format = $24.
Quantity label = 'Number of Items'
length = 8 informat = 6. format = 6.
Profit label = 'Profit in USD'
length = 8 informat = 12. format = 12.2
field163 label = 'Short Field'
length = $ 163 informat = $163. format = $163. ;
keep quarter product_group quantity profit field163;
rc = filename( 'clippy' , ' ' , 'clipbrd' );
if ( rc ne 0 ) then link err;
fid = fopen( 'clippy' , 's' , 32767 , 'V' );
if ( fid eq 0 ) then link err;
A method that works with both Word and Excel, on all
systems, and for records with more than 256 characters
do _n_=1 by 1 while( fread( fid ) = 0 );
rc = fget( fid , _inline_ , 32767 );
_inline_ = transtrn( trim( _inline_ ) , ' ' , '09'x );
if _n_=1 then continue;
quarter = input( scan( _inline_ , 1 , '09'x ) , yyq6.,'m') ;
product_group = scan( _inline_ , 2 , '09'x,'m' ) ;
quantity= input( scan( _inline_ , 3 , '09'x ) , 6.,'m' ) ;
profit = input( scan( _inline_ , 4 , '09'x ) , 12.,'m' ) ;
field163= scan( _inline_ , 5 , '09'x,'m' ) ;
output;
end;
rc = fclose( fid );
rc = filename( 'clippy' );
stop;
err:
do;
m = sysmsg();
put m;
stop;
end;
run;