BookmarkSubscribeRSS Feed
HeatherNewton
Quartz | Level 8

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;

 

 

 

 

 

2 REPLIES 2
Patrick
Opal | Level 21

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;
Kurt_Bremser
Super User

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-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 2 replies
  • 313 views
  • 0 likes
  • 3 in conversation