Viewing SAS Datasets on iPhone

SAS macros are very effective at allowing users to perform analysis by dynamically requesting for reports or views of the data. However, there are times when all the user needs is to view the actual raw data. On the Windows desktop environment, you may use the SAS data viewer. The iPhone has different capabilities such as multi touch pinch to zoom and swipe to slide the views. This can be used to view the data directly and easily. The following illustrates the steps taken to view SAS data on the iPhone.

Step 1 – Selecting Library
SAS datasets are stored in libraries which points to physical folders on the server. This is also refereed to as SAS LIBNAMEs. The main datasets screen on the iPhone contains the latest list of datasets. The first item on this list is the library that is currently being viewed.

By taping on the library right arrow labeled “datlib”, the user drills down to a list of libraries that the user has permissions to. The current selected library is identified with a check mark and colored with standard selected blue tint. The user can then select any other library can by taping on the desired library.

Step 2 – Select Data
The main dataset list displays all dataset names along with the associated label available within the selected library. This can be efficiently scrolled through by using the vertical swipe action which is standard for the iPhone interface. The user can then select the data to be viewed by taping on the right arrow or anywhere in the row of the dataset. The text size and layout of the dataset list is optimized for the user selection within the iPhone interface.

Step 3 – View Data
Upon the specific data selection, a data viewer is presented with all the rows of the data. Chunks of the data of delivered to the iPhone which can be configured. In this example, 20 rows at a time are displayed. The user can then jump to specific blocks of data using the next and previous buttons or the horizontal slider control to navigate to specific chunks of the data.

The interface has been modeled after other existing standard iPhone applications such as iPod player which has standard buttons and layout. Apple has devoted extensive research into developing a user interface that is user friendly for the mobile device optimizing object size and placement for optimal functionality. Many of the same user elements are implemented in this data viewer leveraging upon Apple’s standard to enhance user’s experience. Since users who own an iPhone are most likely familiar with the interface of an iPod to select music, they do not have to learn a new interface for selecting and viewing datasets. In the list view, the selection and viewing of datasets is analogous to playing and selecting options of each song being played on the iPod.

The code and algorithm logic that goes into developing the SAS application server and iPhone client application is extensive. This section will select one section in step 1 on libraries and describe how this is accomplished. The following steps are applied to present the list of library screen.

Step 1 – Capture Libraries
A SAS program is initiated on the server to capture all libraries available. It is then compared to the user permissions before the final list is sent to the client iPhone. The following example code is used to capture this is:

   do while(fetchobs(dsid,cnt) = 0);

libname1 = upcase(getvarc(dsid,varnum(dsid,'libname')));

if libname1 not in ('WORK','SASUSER','SASHELP','SASMSG','MAPS',


if searchc(liblst, libname1, 1, 1, 'Y') = 0 then do;

rc = insertc(liblst,libname1,-1);

path = lowcase(getvarc(dsid, varnum(dsid, 'libpath')));

idx = index(path, '\');

path = substr(path, idx);

path = tranwrd(path, '\', '/');

rc = insertc(pathlst, path, -1);



cnt = cnt + 1;


dsid = close(dsid);

In this case, it captures libraries from the SASHELP.VSLIB view and inserts its findings into a list to be used later.

Step 2 – Subset user Privileges
A SAS program is initiated on the server to capture all libraries available. It is compared to the user permissions access control list. BI Flash stores all the user permissions as described in the permission section above.

Step 3 – XML Library List
Once the final list of library is captured, an XML file is created capturing all the libraries as shown here.


<Library id="1">





<Library id="2">





<Library id="3">







This is information is then delivered to the iPhone via a web server used to for the user selection.


Popular posts from this blog

Clinical Trials Terminology for SAS Programmers

Remembering Dad