The SAS Output Delivery System and reporting techniques

Direct Access to Table Cells

Reply
N/A
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.
SAS Super FREQ
Posts: 8,866

Re: Direct Access to Table Cells

Posted in reply to deleted_user
Hi:
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:
[pre]
ods html file='c:\temp\row25.html';

proc print data=sashelp.shoes(firstobs=25 obs=25);
title 'Report on Row 25';
run;

ods html close;
[/pre]

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:
[pre]
ods html file='c:\temp\row25sales.html';

proc print data=sashelp.shoes(firstobs=25 obs=25);
title 'Report on Row 25 sales';
var sales;
run;

ods html close;
[/pre]

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.

cynthia
Ask a Question
Discussion stats
  • 1 reply
  • 124 views
  • 0 likes
  • 2 in conversation