Sample 24797: Assign a variable's name as the value of a new variable
Use CALL VNAME to assign the name of the variable specified
in the first argument as the value of the variable named in
the second argument.
Note: Be sure to issue a length statement for the new variable
created by CALL VNAME to avoid truncation.
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
/*************************************************************************/
/* In this example, we are searching for any class that has more than 24 */
/* students. If a class is found that meets this criteria, we want to */
/* output the teacher's name and the class in question. */
/*************************************************************************/
data classes;
length new $10;
input teacher :$9. period1 period2 period3 lunch period4 period5;
/* Assign all numeric variables to array CHECK */
array check(*) _numeric_;
do i=1 to dim(check);
if check(i) > 24 then do;
call vname (check(i),new);
put teacher 'has ' check(i) 'students in ' new ;
end;
end;
datalines;
Crabapple . 25 14 . 22 24
Crump 17 15 28 . . 20 18
Kotter 12 12 12 . . 12 4
;
These sample files and code examples are provided by SAS Institute
Inc. "as is" without warranty of any kind, either express or implied, including
but not limited to the implied warranties of merchantability and fitness for a
particular purpose. Recipients acknowledge and agree that SAS Institute shall
not be liable for any damages whatsoever arising out of their use of this material.
In addition, SAS Institute will provide no support for the materials contained herein.
OUTPUT to SAS log
Crabapple has 25 students in period2
Crump has 28 students in period3
Use CALL VNAME to assign the name of the variable specified
in the first argument as the value of the variable named in
the second argument.
Type: | Sample |
Topic: | SAS Reference ==> DATA Step SAS Reference ==> CALL routines
|
Date Modified: | 2005-12-08 11:34:35 |
Date Created: | 2004-09-30 14:09:15 |
Operating System and Release Information
SAS System | Base SAS | All | n/a | n/a |