Hi I want to know the sequence of how sas process the code...
proc sort data=cch (drop=date) out=book nodupkey; by post_to_acct; run;
am I right to think the following sequence from the above code...
1. drop date
2. sort by post_to_acct;
3. drop duplicate
4. output to book
I am tempted to write as follows, ie dropping duplicate and variable "date" before sorting, would the result be the same?
Select distinct post bookcart cake lemon;
from cch;
order by post_to_acct;
run;
I am tempted to write as follows, ie dropping duplicate and variable "date" before sorting, would the result be the same?
Why don't you try?
The SQL you've posted only requires a single semicolon at the end.
proc sql;
create table book_2 as
Select distinct post, bookcart, cake, lemon
from cch
order by post_to_acct
;
quit;
The SQL procedure is an "interactive" procedure; all statements are executed immediately (no RUN is needed), and it must be terminated with a QUIT.
The SELECT is a single statement which also contains the FROM and ORDER BY clauses, so remove the in-between semicolons.
While DROP= removes the explicitly named variables and keeps all others, SELECT keeps the named variables and drops all others, so the behavior is different depending on the "other" variables not mentioned in the dataset option/SQL statement.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.