Help using Base SAS procedures

how to locate a variable in a SAS data set quickly

Reply
Super Contributor
Posts: 338

how to locate a variable in a SAS data set quickly

Hi Colleagues,

The data set now I am working with having over 1500 variables. I know the names of each and every variables based on data dictionary but could you let me know how to locate a given variable immediately.

I tried Ctrl + F approach like in Excel but doesn't work.

Thanks

Mirisage
Super Contributor
Super Contributor
Posts: 3,174

Re: how to locate a variable in a SAS data set quickly

Please help by explaining from where you want to do your "variable find" command?

You can use PROC CONTENTS and do a FIND in the OUTPUT window, as one idea.

Scott Barry
SBBWorks, Inc.
Super Contributor
Posts: 338

Re: how to locate a variable in a SAS data set quickly

Hi sbb,

Thanks.

I need to find a given variable in an opened SAS dataset itself. Say you open a SAS dataset, and you need to find the 'age' variable quickly to get some understanding how do the records under that variable look like.

If there is no quick way to find it, I have to go all variables one by one along headline (first raw) of the data set.

Thanks

Mirisage
SAS Super FREQ
Posts: 8,739

Re: how to locate a variable in a SAS data set quickly

Hi:
I don't understand where the SAS dataset is opened -- in Enterprise Guide?? In the Viewtable window from the SAS Explorer??

For data exploration, I find the best method of reviewing data is to use something like PROC MEANS or PROC UNIVARIATE for numeric variables and to use PROC FREQ for character variables.

Something like the program below, using SASHELP.CLASS.

cynthia
[pre]
ods html file='c:\temp\explore.html' style=sasweb;
** Run the procedures with only your variable of choice;
proc freq data=sashelp.class nlevels;
title '1a) Look at Specific Variable';
tables age;
run;

proc univariate data=sashelp.class;
title '1b) Look at AGE with Univariate';
var age;
run;

proc means data=sashelp.class;
title '1c) Look at AGE with Proc MEANS';
var age;
run;

** Alternately, Explore all character and numeric variables in one procedure;
proc freq data=sashelp.class nlevels;
title '2a) Look at all Character Variables';
tables _character_;
run;

proc univariate data=sashelp.class;
title '2b) Look at Numeric Variables with Univariate';
var _numeric_;
run;

proc means data=sashelp.class;
title '2c) Look at Numeric Variables with Proc MEANS';
var _numeric_;
run;
ods html close;
[/pre]
Super Contributor
Posts: 338

Re: how to locate a variable in a SAS data set quickly

Hi Cynthia,

SAS dataset is opened in the Viewtable window from the SAS Explorer.

The first row is like this which shows variable names.

ID Age Sex Occupation Income Land_owned Disabled Weight............and so on

Say I want to jump into the 'Disabled' variable at once. How should I do it?

Thanks

Mirisage
Super Contributor
Super Contributor
Posts: 3,174

Re: how to locate a variable in a SAS data set quickly

With SAS 9.1.3, I observed a few options - right-click the object, then click VIEW_COLUMNS, or open the file and then click EDIT, then FIND.

Scott Barry
SBBWorks, Inc.
PROC Star
Posts: 1,555

Re: how to locate a variable in a SAS data set quickly

You can also use the form view if you want to show more variables at once (though it has display issues with long variables). There is also the hide/unhide tool, and the hold option to keep some variables permanently displayed when you scroll, but to be honest this interface is obsolete (which is a shame as it is really useful). For eg, the find field in "view columns" requires you to know and enter the whole variable name, or the hide/unhide dialog is tiny and only shows the first eight letters of the variable names. And there is no Goto option to go to a column or to a row/value.

With FSView, you can type 85 to go to row 85, and both goto options are there, but this was not carried over to viewtable.

I raised these issues years ago with tech support, but nothing happened.

Try fsview see if the "go to variable" menu entry works for you. Be warned though, if you have no mainframe experience, the looks and (lack of) features may frighten you ;o)
Valued Guide
Posts: 2,174

Re: how to locate a variable in a SAS data set quickly

since that is now classified as "the old-fashioned sas", you may have the old-fashioned sas module called fsview and fsbrowse. These allow you to go directly to a variable ("disabled" in the example below) with the command
=disabled

Pity it's not so easy in the "more up-to-date" SAS

PeterC
Ask a Question
Discussion stats
  • 7 replies
  • 134 views
  • 0 likes
  • 5 in conversation