SAS Component Language Dictionary |
Category: | SAS Table |
Syntax | |
Details | |
Example | |
See Also |
Syntax |
cval=GETVARF(table-id,col-num); |
is the formatted value of the table column that is returned by GETVARF.
Type: Character
is the identifier for a table that is open. If table-id is invalid, the program halts.
Type: Numeric
is the number of the column in the Table Data Vector (TDV). This value can be obtained by using the VARNUM function. If the column specified in col-num is invalid, the program halts.
Type: Numeric
Details |
GETVARF assigns the formatted value of a SAS table column to a character SCL variable. If no format has been assigned to the specified column, GETVARF returns the raw value for a character column or the value formatted with BEST12. for a numeric column. The length of the returned value is the width of the format.
Example |
This example first creates a SAS table with a character column, NAME, and two numeric columns, BDAY and GENDER. It then reads each row from the table and prints the values of each column plus the formatted values of the two numeric columns.
control asis; submit continue; proc format; value sexfmt 1='Male' 2='Female'; data work.samplef; input name $ 1-10 bday date. gender; format bday date. gender sexfmt. ; cards; Jane 16oct63 2 Bill 15may62 1 Mary 25jan64 2 ; endsubmit; id = open ( 'work.samplef'); do while (fetch(id) NE -1); name = getvarc ( id, 1); bdayn = getvarn (id, 2); bday = getvarf (id, 2); gendern = getvarn (id, 3); gender = getvarf (id, 3); put name= bdayn= bday= gendern= gender=; end; rc = close (id);
The output would be like the following:
name=Jane bdayn=1384 bday= 16OCT63 gendern=2 gender=Female name=Bill bdayn=865 bday= 15MAY62 gendern=1 gender=Male name=Mary bdayn=1485 bday= 25JAN64 gendern=2 gender=Female
See Also |
Copyright © 2009 by SAS Institute Inc., Cary, NC, USA. All rights reserved.