Category
|
Key Combination
|
Action
|
Dialog Boxes and Entry Fields
|
Tab
|
move to next field
|
Shift + Tab
|
move to previous field
| |
Navigate around Text
| ||
Ctrl + -> (right arrow)
|
move to next word
| |
Ctrl + <- (left arrow)
|
move to previous word
| |
Home
|
move to beginning of line
| |
End
|
move to end of line
| |
Ctrl + Home
|
move to top
| |
Ctrl + End
|
move to bottom
| |
Page Up
|
page up
| |
Page Down
|
page down
| |
Ctrl + Page Up
|
move to top
| |
Ctrl + Page Down
|
move to bottom
| |
Ctrl + Tab
|
navigate to the next open SAS window (NEXTWIND command)
| |
Ctrl + Shift + Tab
|
navigate to the previous open SAS window (PREVWIND command)
| |
Mark Text
|
Shift + -> (right arrow)
|
mark while going to the right
|
Shift + <- (left arrow)
|
mark while going to the left
| |
Shift + Home
|
mark to beginning of line
| |
Shift + End
|
mark to end of line
| |
Shift + Ctrl + Home
|
mark to top
| |
Shift + Ctrl + End
|
mark to bottom
| |
Shift + Page Up
|
page up and mark
| |
Shift + Page Down
|
page down and mark
| |
Shift + Ctrl + Page Up
|
mark to top
| |
Shift + Ctrl + Page Down
|
mark to bottom
| |
Shift + MB1
|
extend the current marked text selection to the click position
| |
Cut, Copy, and Paste
|
Delete
|
delete the next character (or marked text)
|
Ctrl + Delete
|
delete from the insertion point position to the end of the current word
| |
Ctrl + Backspace
|
delete from the insertion point position to the start of the current word
| |
Ctrl + MB1
|
selects the entire line (clicked line)
| |
Ctrl + Z
|
undo previous action
| |
Ctrl + X
|
cut selected text
| |
Ctrl + C
|
copy selected text to paste buffer
| |
Ctrl + V
|
paste text
| |
Window Control
|
Alt
|
switch focus to or from the main menu bar
|
Shift + F5
|
cascade the windows
| |
Shift + F4
|
tile the windows vertically
| |
Shift + F3
|
tile the windows horizontally
| |
Ctrl + F6
|
next window
| |
Alt + F4
|
exit SAS
| |
Ctrl + F4
|
close the active window
| |
Ctrl + W
|
access new SAS explorer window
| |
Shift + F10
|
open pop-up menu
| |
Resizing the Docking View
|
Alt + W + S
|
start docking view resizing
|
-> (right arrow)
|
move the split bar a small amount to the right
| |
<- (left arrow)
|
move the split bar a small amount to the right
| |
Ctrl + -> (right arrow)
|
move the split bar a larger amount to the right
| |
Ctrl + <- (left arrow)
|
move the split bar a larger amount to the left
| |
Home
|
move the split bar all the way to the left
| |
End
|
move the split bar all the way to the right
| |
Return
|
accept the current size of the docking view and exit docking view resizing
| |
Esc
|
end docking view resizing without resizing the docking view
| |
Miscellaneous
| ||
Alt + Enter
|
open the Properties dialog box for a selected object
| |
This command is valid only in a Tree view or a List view.
| ||
Esc + letter (or number)
|
color or highlighting attributes in NOTEPAD window
|
Clinical SAS
Tuesday, 4 April 2017
Keyboard Shortcuts within the SAS Main Window
Saturday, 9 April 2016
SAS Arrays
SAS Arrays : Introduction
It provides a simple, appropriate way to process a group of variables in a SAS DATA step.
Syntax
Array array-name {number-of-elements} list-of-variables;
Note: You can use [ ] or { } or ( ) for defining number of elements in the ARRAY statement.
Friday, 8 April 2016
Cartesian Product
1) Cartesian Product
A simplest join in proc sql where the final out is each row of first dataset combined with each row of the second. Its syntax is:
Proc sql;
create table company as
select a.empid, b.name, b.salary
from employee as a , salary as b
;
Quit;
Here the final output will be product of all rows from the employee dataset with all rows in the salary dataset.
Practically this looks wrong as everyone’s salary will be everyone others’ salary, perfect Socialism J
But surprisingly this Cartesian product is the basis of all joins. Whenever you specify a join a Cartesian product is done and the output rows are restricted by certain conditions. So knowing this is necessary.
2) Cartesian Product through a datastep
This technique is not very intuitive but is asked in a lot of interviews so I am including it here:
data every_combination;
/* Set one of your data sets, usually the larger data set */
set one;
do i=1 to n;
/* For every observation in the first data set, */
/* read in each observation in the second data set */
set two point=i nobs=n;
output;
end;
run;
This technique creates a product of all rows.
So above is the hint for answering the question in merging SAS datasets with different id variables names. Let’s see whether you can find the answer.
for more click here or click here
Wednesday, 6 April 2016
Proc SQL joins
A Proc SQL join works same as a datastep merge to combine two or more SAS datasets. There are many types of SQL joins which can be used based on your output requirements.
1) Inner Join
An inner join provides only the matching rows from both datasets. Its syntax is:
Proc sql;
create table company as
select a.empid, b.name, b.salary
from employee as a inner join salary as b
where a.empid=b.emp_id;
Quit;
Here the final output will be all the employees having their salary information in the salary dataset. If the info for a employee is found in any one of the datasets then that employee will not be present in the final table.
1a) Inner Join with datastep:
The same inner join can be performed with a datastep merge.
data company;
merge employee(in=a) salary(rename=(emp_id=empid) in=b);
by empid;
if a and b;
run;
We required the rename as datastep cannot perform a merge on id variables with different names.
Actually there is a way to merge by differently named id variables but that method is at from the notion of elegant coding and is just developed as a workaround as you can always rename id variables easily.
OK OK If you require it so much I will discuss the method towards the end.
2) Outer Join (Left)
A Left Outer join outputs the matching rows from both datasets as well as it also outputs the non-matching from the left dataset or the dataset specified first in the query. Its syntax is:
Proc sql;
create table company as
select a.empid, b.name, b.salary
from employee as a left outer join salary as b
where a.empid=b.emp_id;
Quit;
Here the final output will be all the employees whether or not they have their salary information in the salary dataset. If you want to list all the employees irrespective of their salary being updated in the salary dataset then you will use left outer join.
2a) Left outer Join with datastep:
The same join can be performed with a datastep merge. We just need to change the IF condition.
data company;
merge employee(in=a) salary(rename=(emp_id=empid) in=b);
by empid;
if a;
run;
3) Outer Join (Right)
A Right Outer join outputs the matching rows from both datasets as well as it also outputs the non-matching from the right dataset or the dataset specified second in the query. Its syntax is:
Proc sql;
create table company as
select a.empid, b.name, b.salary
from employee as a right outer join salary as b
where a.empid=b.emp_id;
Quit;
Here the final output will be all the employees who have their salary information in the salary dataset as well as the employees who are not currently updated in employee dataset but their salary info was updated. The situation looks silly but in this case you will be using a right outer join.
One point to note here is that we are taking empid from the employee dataset so for these non-matching employees of the salary dataset the empid will be missing which is definitely not desirable. So as a precaution we generally use the COALESCE function in right outer joins.
Proc sql;
create table company as
select coalesce(a.empid,b.emp_id), b.name, b.salary
from employee as a left outer join salary as b
where a.empid=b.emp_id;
Quit;
This will solve the problem of missing employee ids.
3a) Right Outer Join with datastep:
The right outer join can be performed with a datastep merge similarly as the left outer.
data company;
merge employee(in=a) salary(rename=(emp_id=empid) in=b);
by empid;
if b;
run;
4) Full Join
A Full join as you have rightly guessed by now outputs the matching rows from both datasets as well as it also outputs the non-matching from both the datasets. Its syntax is:
Proc sql;
create table company as
select coalesce(a.empid,b.emp_id), b.name, b.salary
from employee as a full join salary as b
where a.empid=b.emp_id;
Quit;
Here the final output will be all the employees who have their salary information either in the salary dataset or the employee dataset.
Here also we use COALESCE function or the same reason as in Right outer join.
4a) Full Join with datastep:
The full join can also be performed with a datastep merge. We just need to eliminate the if condition or for better understanding we can keep the condition as IF A OR B;
data company;
merge employee(in=a) salary(rename=(emp_id=empid) in=b);
by empid;
if a or b;
run;
for more click here
Subscribe to:
Posts (Atom)