FILENAME, CLIPBOARD Access Method

Enables you to read text data from and write text data to the clipboard on the host computer.
Valid in: Anywhere
Category: Data Access

Syntax

Arguments

fileref
is a valid fileref.
CLIPBRD
specifies the access method that enables you to read data from or write data to the clipboard on the host computer.
BUFFER=paste-buffer-name
creates and names the paste buffer. You can create any number of paste buffers by naming them with the BUFFER= argument in the STORE command.

Details

The FILENAME statement, CLIPBOARD Access Method enables you to share data within SAS and between SAS and applications other than SAS.

Comparisons

The STORE command copies marked text in the current window and stores the copy in a paste buffer.
You can also copy data to the clipboard by using the Explorer pop-up menu item Copy Contents to Clipboard .

Examples

Example 1: Using ODS to Write a Data Set as HTML to the Clipboard

This example uses the Sashelp.Air data set as the input file. The ODS is used to write the data set in HTML format to the clipboard.
filename _temp_ clipbrd;
   ods noresults;
   ods html file=_temp_ rs=none style=minimal;
   proc print data=Sashelp.'Air'N noobs;
run;
ods results;
filename _temp_;

Example 2: Using the DATA Step to Write a Data Set as Comma-separated Values to the Clipboard

This example uses the Sashelp.Air data set as the input file. The data is written in the DATA step as comma-separated values to the clipboard.
filename _temp1_ temp;
filename _temp2_ clipbrd;
proc contents data=Sashelp."Air"N out=info noprint;
proc sort data=info;
   by npos;
run;
data _null_;
   set info end=eof;
   ;
   file _temp1_ dsd;
   put name @@;
   if _n_=1 then do;
      call execute("data _null_;
      set Sashelp.""Air""N; 
      file _temp1_ dsd mod; 
      put");
   end;
   call execute(trim(name));
   if eof then call execute('; run;');
run;
data _null_;
   infile _temp1_;
   file _temp2_;
   input;
   put _infile_;
run;
filename _temp1_ clear;
filename _temp2_ clear;

Example 3: Using the DATA Step to Write Text to the Clipboard

This example writes three lines to the clipboard.
filename clippy clipbrd;
data _null_;
   file clippy;
   put 'Line 1';
   put 'Line 2';
   put 'Line 3';
run;

Example 4: Using the DATA Step to Retrieve Text from the Clipboard

This example writes three lines to the clipboard and then retrieves them.
filename clippy clipbrd;
data _null_;
   file clippy;
   put 'Line 1';
   put 'Line 2';
   put 'Line 3';
run;
data _null_;
   infile clippy;
   input;
   put _infile_;
run;

See Also

Commands:
The STORE command in the Base SAS Help and Documentation