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.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.