Help using Base SAS procedures

proc sql case when

Posts: 29

proc sql case when



I am a new programmer and hope to get some help.I've already created a table. However, some codes can not be grabed because of the applicationdate not equal to codesdate. So I want to add the blank obs from the previous applicationdate.  I am not quite sure whether can I use proc sql case when like this as below:


proc sql;

 create table new as

    select origianl*

              case when codes=' ', then where codesdate=min(original.codesdate)


              end as codes;



whehter can I use other more simple logic for example data; set; My goal is to look back to the rules table where the codedate is min() when the codes are blank and the rest keep their original value. 


thank you.

Super User
Super User
Posts: 9,599

Re: proc sql case when

Posted in reply to septemberbulb

Start by posting some test data - in the form of a datastep.  Follow this post if you need to:


Secondly, your SQL statement is invalid in several ways, first you have no "from" clause, second origianl* - is invalid.

Post what you have, and show what you want at the end.  Note you don't necessarily need to use SQL, but its hard to advise on the limited information you have provided.

Super User
Posts: 10,280

Re: proc sql case when

Posted in reply to septemberbulb

Please supply some example data (in a data step) for us to play around with, and so we get a feel for your data structure.

And post the desired result.

Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Ask a Question
Discussion stats
  • 2 replies
  • 3 in conversation