Advanced cert study Flashcards
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