jvm.97
jvm.97

Reputation: 247

Complete empty cells of a table with specific value SAS

I'm working on a table in SAS with a column that contains dates (FENTREGA in the picture), i want to complete the empty cells of this column with "Empty", can you help me with the code? This is the structure of my table, the column i need to use is FENTREGA.

enter image description here

enter image description here

Upvotes: 0

Views: 763

Answers (1)

Reeza
Reeza

Reputation: 21274

Since your column is numeric you cannot put text in the same column. However, you can make the period appear as the text EMPTY if you use a custom format. Or you can make the whole column text, but then you cannot do date operations/calculations on the column without converting it back.

proc format;
value empty_dates
. = 'Empty'
Other = [mmddyyd10.];
run;

proc sql;
....

t1.FENTREGA format=empty_dates.,
....

EDIT: Fully tested solution, works as expected

DATA have;
informat FENTREGA mmddyy10.;
format FENTREGA date9.;
input  FENTREGA;
datalines;
 12/10/2003
 10/15/2006
 07/20/2010
 05/11/2006
 10/01/2006
 07/03/2012
 05/08/2015
 .
 .
 .
 .
;
RUN;
 
proc format;
value empty_dates
. = 'Empty'
Other = [mmddyyd10.];
run;

proc sql;
select
FENTREGA format=empty_dates.
from have;
quit;

Upvotes: 1

Related Questions