What does the ampersand ("&") do in a statement?

I am familiar with the modifiers :

, and ~

in the SAS manuals put

and input

. The behavior &

in the statement is input

also fairly well documented. But what does &

the expression put

do?

It seems to be similar :

, causing modified list output rather than formatted output, but I can't find any documentation about this behavior.

eg.

data _null_;
  set sashelp.class;
  file 'c:\temp\output.csv' dlm=',';
  put Name Sex Age & 4. Height Weight;
run; 

      

+3


source to share


1 answer


Quote from online documentation in SAS 9.4 section in INPUT, List statement

&

      

indicates that a symbol value can have one or more separate inline stubs. This format modifier reads the value from the next non-empty column until the pointer reaches two consecutive spaces, the specified length of the variable, or the end of the input string, whichever comes first.

Restriction: The modifier must follow the variable name and the $ sign it affects.

Hint: If you specify the informat after the modifier, the termination condition for the format modifier will remain with two spaces.

Here's an example from an example:

Example Reading character data containing contained spaces

The INPUT statement in this DATA step uses the modifier and list-type format to read character values ​​that contain embedded spaces.



data list;
   infile file-specification;
   input name $ & score;
run;

      

It can read these input data records:

----+----1----+----2----+----3----+
Joseph   11 Joergensen  red
Mitchel  13 Mc Allister  blue
Su Ellen  14 Fischer-Simon  green

      

The modifier follows a variable that affects the INPUT statement. Since this format modifier follows NAME, at least two spaces must separate the NAME field from the SCORE field in the input.

You can also specify an informative with a format modifier as shown below:

input name $ & +3 lastname & $15. team $;

      

In addition, this INPUT statement reads the same data to demonstrate that you do not need to read all the values ​​in the input record. The column pointer +3 moves the pointer past the score value to read the value for LASTNAME and TEAM.

+1


source







All Articles