BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Nehemiah
Calcite | Level 5

Dear All

 

bellow is the code i run :

 

Data SAm;
input Name $ Item $ Value ;
cards;
nehemiah ball 20
nehemiah bat 100
nehemiah glouse 50
naari battary 14
naari remote 40
naari cover 120
;
Run;

 

I want output like this

 

output:

 

naari    battary  14

nehemiah ball 20

 

 

please help me with the code Proc Sql

 

1 ACCEPTED SOLUTION

Accepted Solutions
PeterClemmensen
Tourmaline | Level 20

Good. Please mark my answer as an accepted solution to help future users navigate the community

View solution in original post

5 REPLIES 5
PeterClemmensen
Tourmaline | Level 20

I assume that what you want is to take the obs with the minimum value for each name? If you want to do so with PROC SQL, this has nothing to do with first./last. logic, which is a SAS Data Step concept. 

 

proc sql;
    create table want as
    select * from sam
    group by name
    having value=min(value);
quit;

 

Result:

 

name      item     value

naari     battary  14   
nehemiah  ball     20    

 

Nehemiah
Calcite | Level 5

thanks for the Solution.

 

and wrote a code in data step like this


Proc sort Data =Sam out=Sam_srt ;
By Name ;
Run;

 

Data Sam_1 ;
Set Sam_srt;
By Name ;
If First.name ;
Run;

 

Sir 

i want output based on Name only.and can you write the code for above data step into Proc SQL.

 

 

 

 

PeterClemmensen
Tourmaline | Level 20

Have you tried my code above?

Nehemiah
Calcite | Level 5
yeah..its working perfectly..
PeterClemmensen
Tourmaline | Level 20

Good. Please mark my answer as an accepted solution to help future users navigate the community

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!

Mastering the WHERE Clause in PROC SQL

SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 5 replies
  • 1036 views
  • 0 likes
  • 2 in conversation