CALL SET Routine


Links SAS data set variables to DATA step or macro variables that have the same name and data type

Category: Variable Control

Syntax

CALL SET ( data-set-id );

Arguments

data-set-id

  • is the identifier that is assigned by the OPEN function when the data set is opened.

Details

Using SET can significantly reduce the coding that is required for accessing variable values for modification or verification when you use functions to read or to manipulate a SAS file. After a CALL SET, whenever a read is performed from the SAS data set, the values of the corresponding macro or DATA step variables are set to the values of the matching SAS data set variables. If the variable lengths do not match, the values are truncated or padded according to need. If you do not use SET, then you must use the GETVARC and GETVARN functions to move values explicitly between data set variables and macro or DATA step variables.

As a general rule, use CALL SET immediately following OPEN if you want to link the data set and the macro and DATA step variables.

Examples

This example uses the CALL SET routine:

  • The following statements automatically set the values of the macro variables PRICE and STYLE when an observation is fetched :

     %macro setvar;     %let dsid=%sysfunc(open(sasuser.houses,i));        /* No leading ampersand with %SYSCALL */     %syscall set(dsid);     %let rc=%sysfunc(fetchobs(&dsid,10));     %let rc=%sysfunc(close(&dsid));  %mend setvar;  %global price style;  %setvar  %put _global_; 
  • The %PUT statement writes these lines to the SAS log:

     GLOBAL PRICE 127150  GLOBAL STYLE CONDO 
  • The following statements obtain the values for the first 10 observations in SASUSER.HOUSES and store them in MYDATA:

     data mydata;        /* create variables for assignment */        /*by CALL SET */     length style  sqfeet bedrooms baths 8        street  price 8;     drop rc dsid;     dsid=open("sasuser.houses","i");     call set (dsid);     do i=1 to 10;        rc=fetchobs(dsid,i);        output;     end;  run; 

See Also

Functions:

  • 'FETCH Function' on page 523

  • 'FETCHOBS Function' on page 524

  • 'GETVARC Function' on page 572

  • 'GETVARN Function' on page 573




SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
SAS 9.1 Language Reference Dictionary, Volumes 1, 2 and 3
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 704

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net