regarding proc sql

Occasional Contributor lg2
Occasional Contributor
Posts: 6

regarding proc sql

I have database with diagnosis description.(example like mood disorders,sleep disorders..)I want to find the diagnosis id with that description.How to create a program for that?

SAS Moderator
Posts: 62

Re: regarding proc sql [how to improve your question]

Hello @lg2,

Your question requires more details before experts can help. Can you revise your question to include more information? 


Review this checklist:

  • Specify a meaningful subject line for your topic.  Avoid generic subjects like "need help," "SAS query," or "urgent."
  • When appropriate, provide sample data in text or DATA step format.  See this article for one method you can use.
  • If you're encountering an error in SAS, include the SAS log or a screenshot of the error condition. Use the Photos button to include the image in your message.
  • It also helps to include an example (table or picture) of the result that you're trying to achieve.

To edit your original message, select the "blue gear" icon at the top of the message and select Edit Message.  From there you can adjust the title and add more details to the body of the message.  Or, simply reply to this message with any additional information you can supply.



SAS experts are eager to help -- help them by providing as much detail as you can.


This prewritten response was triggered for you by fellow SAS Support Communities member @Reeza

Valued Guide
Posts: 596

Re: regarding proc sql

You need to provide some more information on what data you have.

If you have a table with diagnosis and another table with there codes then a simple left join works. 

data D_id;
infile datalines dlm=',' missover;
input id diagnosis $25.;
101,mood disorders
102,sleep disorders

data have;
infile datalines dlm=',' missover;
input patient diagnosis $25.;
datalines ;
1,mood disorders
2,mood disorders
3,sleep disorders
4,sleep disorders

proc sql;
create table want as 
select a.*,
from have a
left join d_id b on a.diagnosis=b.diagnosis


Posts: 9,370

Re: regarding proc sql

Posted in reply to SuryaKiran


  And, another approach is to use a FORMAT for a table lookup. In the example below, the PROC FORMAT was hardcoded, but you can build the format from a SAS dataset, too.



In this example, the value of the DIAGCODE variable will come from the $dgcode user defined format. This is another way to do a table lookup without doing a merge or a join.



Ask a Question
Discussion stats
  • 3 replies
  • 4 in conversation