Sometimes I need to see specific observations in large data sets. For example,
data have;
do i=1 to 100000;
x=rannor(1);
y=x+rannor(1);
output;
end;
run;
And suppose I want to see the 12,345th observation in the 100,000-observation data set as follows.
Usually I use (1) the page-up and page-down keys or (2) the up-arrow and down-arrow keys, or (3) drag the right scroll bar. In Excel I can use the F5 key to go to specific cells. I wonder whether SAS has something similar, both vertically and horizontally, though the above example is only a vertical case.
If you have the Viewtable open you can use Ctrl-F to bring up a search window that you can use to indicate a variable and value to search for.
If you want a command in the SAS command box you can type:
vt have; find i=75;
note the ; to delimit commands. The box will open with that line.
If you don't have a variable you can try:
vt have; forward 75;
The first time the VT window opens it would go forward (toward the end of the file) 75 lines. However it is not a row number reference.
If you expect this to be opened in code then you use the DM command:
dm "vt have; find 75;";
or
dm "vt have; forward 75;";
If the data set you want is the last created one you could use _last_ in place of the data set name.
There isn't really anything similar for variables. There is a COLUMNS command that can show the list of given variable names (only).
That would look like
vt have; columns ' i y';
or if you have VT open the Columns in the command box (that first box on the left in the menu bar next to the check mark)
You could use HIDE or UNHIDE as well to manipulate the current variables shown.
If you have the Viewtable open you can use Ctrl-F to bring up a search window that you can use to indicate a variable and value to search for.
If you want a command in the SAS command box you can type:
vt have; find i=75;
note the ; to delimit commands. The box will open with that line.
If you don't have a variable you can try:
vt have; forward 75;
The first time the VT window opens it would go forward (toward the end of the file) 75 lines. However it is not a row number reference.
If you expect this to be opened in code then you use the DM command:
dm "vt have; find 75;";
or
dm "vt have; forward 75;";
If the data set you want is the last created one you could use _last_ in place of the data set name.
There isn't really anything similar for variables. There is a COLUMNS command that can show the list of given variable names (only).
That would look like
vt have; columns ' i y';
or if you have VT open the Columns in the command box (that first box on the left in the menu bar next to the check mark)
You could use HIDE or UNHIDE as well to manipulate the current variables shown.
forward
is exactly what I wanted—columns
is also useful.
May I add a little silly question? I have used SAS more than five years and sometimes use dm
functions such as log;clear;output;clear;
but have never though about the command box. Where can I more find the command box functions?
@Junyong wrote:
forward
is exactly what I wanted—columns
is also useful.May I add a little silly question? I have used SAS more than five years and sometimes use
dm
functions such aslog;clear;output;clear;
but have never though about the command box. Where can I more find the command box functions?
The SAS documentation. Search for Command.
Or topics like VIEWTABLE.
data have; do i=1 to 100000; x=rannor(1); y=x+rannor(1); output; end; run; data temp; n=12345; set have point=n; output; stop; run; proc print noobs;run;
Hello @Junyong,
In my opinion, the SAS Universal Viewer is superior to a VIEWTABLE window when it comes to viewing SAS datasets. One of its advantages is that it doesn't lock the datasets being viewed (see, e.g., this thread: Close all VIEWTABLES). And of course it has the "Go to row ..." feature:
Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.
Register today!What’s the difference between SAS Enterprise Guide and SAS Studio? How are they similar? Just ask SAS’ Danny Modlin.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: