The SAS Output Delivery System and reporting techniques

Direct Access to Table Cells

Not applicable
Posts: 0

Direct Access to Table Cells

In a table, how to get a direct access to a cell, for example, if I wish in a program to obtain the value of the fifth variable, 25th observation? Please provide an example.

Thanks in advance for your assistance.
Posts: 9,365

Re: Direct Access to Table Cells

Posted in reply to deleted_user
This is not an ODS or BASE Reporting procedure question (PRINT, REPORT, TABULATE).

However, you can create a report using PROC PRINT that does some of what you want. Remember that SAS stores information in ROWS and COLUMNS. The data LOOK tabular in structure when you do a report or view them in a table viewer; however, internally, SAS uses a different mechanism (other than a table) for storing the data -- so when you talk about SAS data, you do not, generally, talk about accessing the 5th column on the 25th row.

To get a report of ALL the variables or columns in ROW 25 of SASHELP.SHOES, you could do this:
ods html file='c:\temp\row25.html';

proc print obs=25);
title 'Report on Row 25';

ods html close;

Because SAS stores variable or column NAMES the easiest way to identify the columns you want on the report is by NAME. so, for example, if you wanted only the SALES column information on your report for ROW 25, you would list the SALES column on a VAR statement:
ods html file='c:\temp\row25sales.html';

proc print obs=25);
title 'Report on Row 25 sales';
var sales;

ods html close;

However, if you want to create a query or do any kind of processing based on the value for the SALES column for ROW 25, then you'd have to use programming techniques. Since this is not a forum for programming techniques, your best bet for help with this question is to contact Tech Support.

Ask a Question
Discussion stats
  • 1 reply
  • 2 in conversation