BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Ksharp
Super User

@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.

ImPrem
Obsidian | Level 7

@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!!! 

art297
Opal | Level 21

@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

 

PaigeMiller
Diamond | Level 26

@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.

--
Paige Miller
ballardw
Super User

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.

 

Reeza
Super User

@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. 

ImPrem
Obsidian | Level 7

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!! 

thisisneeraj
Fluorite | Level 6
Dear ImPrem, not only you are dumb, but arrogant as well.. You need to work hard. I'm sure you don't even be knowing concepts of first. And last..
Coming back to question, and the silly answer you gave, that answer only gives third highest salary of 'HR' department.... What if dataset has the employee salary records of many department.then how will you solve it.. That is the question I have solved for you...

Please study concept of first., last., proc rank, single trailing, double trailing, as these are the easiest questiona asked in interviews, and i can see you will get silent in hearing the first two interview questions... Can see you are a beginner, and try to bypass the hard work dedication given in learning SAS, and misusing this community platform to get your homeworks done... In This way, i can not see you learning SAS... All the best.... Every above feedback and suggestion was free for you... #muft
Reeza
Super User

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?
art297
Opal | Level 21

@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

 

 

thisisneeraj
Fluorite | Level 6
I sincerely apologise for my harsh comment... I will refrain next time from passing any personal remarks, and will practice only replying to the question .. Learning on the go.. Requesting apologies again.. Kind regards to everyone.

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
  • 26 replies
  • 3558 views
  • 11 likes
  • 7 in conversation