BookmarkSubscribeRSS Feed
nshTi62
Calcite | Level 5

Hi I have simple query in Proc SQL to look for all ID = 0, but my result included both 1 and 0.  The table is in a SQL Server. My query is below

 

Proc SQL;

  Select StudentID

from TBL_Student

where StudentID = 0;

quit;

 

I had tried to the different in where clause but did not work :

 

where put(studentid, $1.) = '0'

where  put(studentid, best.) = 0

where studentid = put(0, $1.)

where studentid = put(0, 1.)

 

Please help.

3 REPLIES 3
novinosrin
Tourmaline | Level 20

Hi @nshTi62  Assuming I understand your requirement

 


Proc SQL;

  Select *  /*all columns*/

from TBL_Student
group by StudentID
having count(distinct StudentID) = 1 and studentid=0;

quit;

 Or if it's not, post a sample of what you HAVE and what you WANT

PGStats
Opal | Level 21

Or, if studentId is a character field, try

 

Proc SQL;
Select *
from TBL_Student
where input(StudentID, best.) = 0;
quit;
PG

sas-innovate-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 3 replies
  • 773 views
  • 1 like
  • 4 in conversation