@art297 ,
I don't think you are contender for me. I think you are partner for me . We both have the same papers in SGF.
Most time I agree with your solution, and of course learn a lot from you too.
I would like to say welcome back sas forum.
@art297: Hi, I'm not getting any error in log, while executing the same sas code.
As i said, i'm a begineer for Base SAS.
Oneday i will reach your level (Expert) definitely but not immediately!! 🙂
Thanks for helping me out!!!
@ImPrem: My comment wasn't meant to imply that SAS would give you an error. It was giving you exactly what you asked it to provide, namely the 3rd HIGHEST score. It has no way to know that what you really wanted was the 3rd lowest score.
Art, CEO, AnalystFinder.com
@ImPrem wrote:
I'm a begineer (Base SAS). For me, its very difficult to understand the sas code. I heard SAS is very simple tool when compare to Excel. But your code was very difficult to understand. Kindly give me very simple SAS code.
If you heard that SAS was very simple, then I suggest that this is incorrect. SAS can get complicated when doing complicated tasks. I doubt you will find simpler code in a data step, otherwise Art would have provided it.
Exactly how you want the results can have a big difference on an approach. If I just wanted to know the value with out the result in a data set I would start with:
Proc univariate data=employeesalary;
var salary.
run;
One of the results will be a list of the 5 largest and 5 smallest values of the variable.
Or just largest and smallest:
Proc means data=employeesalary min max;
var salary;
run;
Means has some options to get top and bottom 3 as well.
@ImPrem You're asking us to do your assignment rather than taking the time to learn. And your instructor will know because you're expected to use the techniques taught in class and the solutions we provide may not align with what you were taught and the type of solution you should be implementing. If you want to learn SAS invest the time to learn, if you're just trying to pass a course for some reason then good luck.
Thank you for your kind friendly advise!! Today @art297 taught me the new technique to do in different way! I'm amazed! Looking forward to do the same task in a different way. So, i will also learn from expert like you people. @Reeza Kindly guide me with some study materials for begineers like me.
Once again thank you very much!!
Ok peoples, @thisisneeraj, @ImPrem, back to your corners.
Please keep it civil.
@ImPrem Please remember you're asking perfect strangers for help, for free. You're asking for a favour, some basic manners should be the minimum here, you're not entitled to any solution or anyone's time. Everyone on here, who doesn't have a SAS employee under their name, is voluntarily helping you.
@thisisneeraj Don't feed the trolls. My approach to these types of comments/questions is to point out they have an unrealistic expectation and 'walk away'. This could mean ignoring either this particular question or ALL questions from that user in the future. At the end of the day, you can choose who to engage with, but name calling is crossing the line, in my opinion.
Something I wrote a while back that may apply here:
Trust – a person on whom or thing on which one relies (Dictionary.com)
Data Science is a difficult field. There isn’t always certainty in the answers, methods or recommendations. What works today may not work tomorrow or in a new field. A new algorithm speeds things up, new information changes the best method, best practices change. Staying on top of all of that is most definitely a challenge. Being a CEO, CIO, or even a Chief Data Scientist is a daunting task. Which is why the people who do the actual day to day work need to be trust worthy. As the CEO or a colleague, I need to trust that you know what you’re doing and that what you recommend is something I can go along with. I may not always be in a place to verify every detail of your work, or sometimes even understand it. So if you’re a douchebag online, insult people online, make sexist remarks in the office at the water cooler or the corporate jet you can’t really be trusted in my opinion. In general, when you can’t trust someone you don’t trust the work they do. So don’t be a douche bag. Online or in real life. Is that really so difficult?
@Reeza: I totally agree with everything you said. The worst part, methinks, was @thisisneeraj's name calling. That should NEVER be done, or allowed, in a forum like this.
@thisisneeraj: You proposed a more complicated by dept solution, while the OP hadn't asked for that. One is free to propose whatever they want, but don't take offense when someone disagrees with you. Name calling, for me at least, is an immediate flag for me to avoid someone. I think you owe @ImPrem an appology. And, FWIW (unless someone knows a trick I'm not aware of), answering this question (either with or without considering dept) isn't that simple. Here is the simplest proc sql solutions I could think of:
data abc; input name $ dept $ sal comma6. loc $; cards; abc HR 32,392 CH ghs MAR 26,378 MY gsi HR 62,362 JU gdi HR 23,379 JK qim HR 83,368 UK own HR 82,738 IK KUW MAR 82,768 OK xyz MAR 50,000 MI xyz MAR 40,000 MI ; proc sql; title "3rd lowest salary"; select * from (select * from (select * from abc having sal ne min(sal)) having sal ne min(sal)) having sal eq min(sal) ; quit; proc sql; title "3rd highest salary"; select * from (select * from (select * from abc having sal ne max(sal)) having sal ne max(sal)) having sal eq max(sal) ; quit; proc sql; title "3rd lowest salary by dept"; select * from (select * from (select * from abc group by dept having sal ne min(sal)) group by dept having sal ne min(sal)) group by dept having sal eq min(sal) ; quit; proc sql; title "3rd highest salary by dept"; select * from (select * from (select * from abc group by dept having sal ne max(sal)) group by dept having sal ne max(sal)) group by dept having sal eq max(sal) ; quit;
@ImPrem:You may have inadvertently started the confrontation by saying that @thisisneeraj's code didn't work. I agree that it was for a more complex question than you were asking, but his/her code definitely worked. You didn't say how it didn't work, or provide a log that showed an error, thus the error may have been due to something you did or didn't do.
Art, CEO, AnalystFinder.com
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.