BookmarkSubscribeRSS Feed
3 REPLIES 3
ChrisNZ
Tourmaline | Level 20

SQL has no concept of row order, and the order is never guaranteed. 

Use a data step instead.

For SQL, this not-recommended code might help:

proc sql;
  select monotonic() as M, mod(calculated M, 2) as ODD
  from SASHELP.CLASS;
quit;

 

Jagadishkatam
Amethyst | Level 16

Please try the below code with mod function to generate the odd and even row tables by proc sql

 

proc sql;
create table odd as SELECT * FROM (select *, monotonic() as row from sashelp.class ) where mod(row,2)<>0;
create table even as SELECT * FROM (select *, monotonic() as row from sashelp.class ) where mod(row,2)=0;
quit;
Thanks,
Jag
ballardw
Super User

What does your input look like, or an example, and what should the output look like?

There can be more than one interpretation of your subject line.

It could be "is the record order value even/odd"

It could be the record number is even/odd (not always the same thing with deleted information)

Is the value of some variable, or combination of variables even/odd.

Is the explicit value of some variable (or variables) the text "even" or "odd".

 

And I suspect that if I spent some time I might come up with a few more. So something specific might be a good idea.

SAS Innovate 2025: Call for Content

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!

Submit your idea!

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
  • 3 replies
  • 2973 views
  • 4 likes
  • 4 in conversation