PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, November 10, 2022

[FIXED] how to Sort negative and positive data in SAS

 November 10, 2022     proc, sas, sorting, sql     No comments   

Issue

I have bellow data in variable NUM

-3 1 0 1 3 2 -2 5 -5 -6 4 6 -4

i want data NUM in bellow sorting order

0 -1 1 -2 2 -3 3 -4 4 -5 5 -6 6

How can we sort negative and positive values together? please help

data have;
input NUM @@;
cards;
-3 1 0 1 3 2 -2 5 -5 -6 4 6 -4
;
run;

Solution

Make a new variable with the absolute value and include it in the sort.

data want;
  set have;
  absolute=abs(num);
run;
proc sort data=want;
  by absolute num;
run;


Answered By - Tom
Answer Checked By - Terry (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing