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.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.