Advanced cert study Flashcards
(31 cards)
proc fcmp
outlib arument is required*
PROC FCMP OUTLIB =libname.dataset.package;
FUNCTION name (parameter-1, …, parameter-N); program-statements; RETURN (expression); ENDSUB; run;
macro loops
%do i=1 %to
%end
works with %do %until and %do %while
subroutine (proc fcmp cont)
SUBROUTINE subroutine-name (argument-1,…, argument-n);
OUTARGS out-argument-1, …, out-argument-n;
… more-program-statements …
ENDSUB;
%str
masks the normal meaning of these tokens: + - * / , < > = ; ‘ “ %NRSTR also mask macro call values
scan function
SCAN(string,n)
breaks up a string into words that can be returned as the value. returns the nth word;
proc sql logic
case when-then when then else end as var
symputx and symget
call symputx(‘var’, value) symget(‘var’)
find function
FIND(string,tgtsubstring)
searches a string for a certain substring returns the position of the first occurence of the substring within the string if found , else 0
Findc(string, charlist, )
returns first occurence of any char else 0
FINDW(string,word);
copying tables
create table tablename
like oldtable: creates an empty table
Create table tablename as query expression; creates table from a query
All and corr
all does not remove matching rows
corr remove nonmatching columns
%scan
%SCAN(argument, n )
returns the nth word of an argument
Union
select * from one union select * from two;
UNION
Unique rows from both tables are selected with columns
overlaid.
select distinct
eliminates duplicate rows in query results
Hash objects
data mem_type; length Code $2 MemberType $40; if _N_=1 then do; declare hash T(); T.definekey('key'); T.definedata('MemberType'); T.definedone(); end; set orion.europe_customers; T.find(); * matches vars with same value otherwise use t.find(key: 'var');
%Eval
%EVAL(expression)
performs arithmetic ops, truncates non int restults, returns 1 or 0 for logical ops, retuns a null value for non-int vals
%local
delcares macro values within a macro function, like a %let statement
inner and outer joins
inner return rows with matching keys, up to 256
outer rows return all rows with matching and nonmatching keys, only can be two at a time
arrays
ARRAY array-name {number-of-elements}
;
2 dim array
ARRAY array-name {…,rows, cols}
;
proc append
proc append base=basetable data=appendtable ; quit;
except
select * from one except select * from two;
Unique rows from the first table that are not found in
the second table are selected.
proc sql contents equi
proc sql:
describe table;
Intersect
select * from one intersect select * from two; Common unique rows from both tables are selected.
set operators
SELECT …
EXCEPT | INTERSECT | UNION | OUTER UNION
SELECT …
where v having clause
The WHERE clause is processed before a GROUP
BY clause and determines which individual rows are
available for grouping.
The HAVING clause is processed after the GROUP
BY clause and determines which groups will be
displayed.