GETCOLUMN Function
Extracts the column into an array.
| Category: | Result Tables |
|---|---|
| Returned data type: | Array |
Table of Contents
Syntax
GETCOLUMN(table-name, column-name | column-number);
Required Arguments
table-name
specifies the name of the table to extract the column from.
column-name
specifies the name of the column to extract into an array.
column-number
specifies the number of the column to extract into an array.
Details
The GETCOLUMN function extracts all of the rows from a column into an array. The column can be specified by column name or column number.
Note: If you specify an invalid
column name or invalid column number, the GETCOLUMN function returns
an empty array.
Note: When you use the GETCOLUMN
function on a STRING column, trailing blanks are added to make all
values of the array the same length. When you use the GETCOLUMN function
on a VARCHAR column, the values of the array are null-terminated and
no trailing blanks are added.
Example: Extract a Column from a Table
This example illustrates how to extract a column from a table into an array.
proc casutil;
load data=sashelp.cars;
quit;
proc cas;
table.fetch result=r / table="cars" to=428;
findcar=findtable(r);
describe findcar;
colarray=getcolumn(findcar, "Make");
print colarray;
run;
quit;
(DESCRIBE Statement
[Fetch] Table ( [50] Rows [16] columns Column Names: [1] _Index_ [ ] (int64) [2] Make [ ] (char) [3] Model [ ] (char) [4] Type [ ] (char) [5] Origin [ ] (char) [6] DriveTrain [ ] (char) [7] MSRP [ ] (double) [DOLLAR8.] [8] Invoice [ ] (double) [DOLLAR8.] [9] EngineSize [Engine Size (L) ] (double) [10] Cylinders [ ] (double) [11] Horsepower [ ] (double) [12] MPG_City [MPG (City) ] (double) [13] MPG_Highway [MPG (Highway) ] (double) [14] Weight [Weight (LBS) ] (double) [15] Wheelbase [Wheelbase (IN) ] (double) [16] Length [Length (IN) ] (double)
(PRINT Statement)
{Acura ,Acura ,Acura ,Audi ,Audi ,Audi ,Audi ,Audi ,Audi ,BMW ,BMW ,BMW ,BMW ,
BMW ,BMW ,BMW ,Buick ,Buick ,Buick ,Cadillac ,Cadillac ,Chevrolet,Chevrolet,Chevrolet,Chevrolet,Chevrolet,
Chevrolet,Chevrolet,Chevrolet,Chevrolet,Chrysler ,Chrysler ,Chrysler ,Chrysler ,Chrysler ,Dodge ,Dodge ,Dodge ,Dodge ,
Dodge ,Ford ,Ford ,Ford ,Ford ,Ford ,Ford ,Ford ,GMC ,GMC ,GMC }
Last updated: August 18, 2026