BookmarkSubscribeRSS Feed
deleted_user
Not applicable
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.
1 REPLY 1
Cynthia_sas
SAS Super FREQ
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

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 1 reply
  • 785 views
  • 0 likes
  • 2 in conversation