Chapter Contents |
Previous |
Next |
GETVARF |
Category: | SAS Table |
Syntax | |
Details | |
Examples | |
Example 1: Print Formatted Table Column Values | |
See Also |
Syntax |
cval=GETVARF(table-id,col-num); |
Type: Character
Type: Numeric
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 _BLANK_ for a numeric column.
Examples |
The 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. sex sexfmt. ; cards; Jane 16oct63 2 Bill 15may62 1 Mary 25jan64 2 ; endsubmit; id = open ( 'work.samplef'); do while (fetch(id)=0 ); name = getvarc ( id, 1); bdayn = getvarn (id, 2); bday = getvarf (id, 2); gender = getvarn (id, 3); fgender = 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 |
Chapter Contents |
Previous |
Next |
Top of Page |
Copyright 1999 by SAS Institute Inc., Cary, NC, USA. All rights reserved.