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

Hello Folks

 

I am a long time reader first time Poster.

I'm a beginner in SAS with no programming/coding background. Currently stuck with a school assignment wherein i have to replace a missing date values in a Column (with existing mmddyy10. format)_with a given date 01/20/2001(mmddyy10.).

i used the following code 


proc format;
value ndate
. = 01/20/2001;
RUN;

proc print data=pipe_2 (obs=20);
FORMAT deactdt ndate.;
RUN;

 

It replaces the missing date values with 01/20/2001, but some how the existing date values in the column converted to actual sas date values.

 

how do i retain those existing date values in their initial assigned format which is MMDDYY10 AND ALSO KEEP THE NEWW REPLACED VALUES TO MMDDYY10.

 

YOUR response will be appreciated.

 

thanks

Have a wonderful day.

 

 

 

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
Astounding
PROC Star

It's not clear whether you are pursuing the proper path or not.  A format changes what prints, but doesn't change the data values themselves.  If changing the data values is the goal, you could try:

 

data pipe_3;

set pipe_2;

if deactdt = . then deactdt = '20jan2001'd;

run;

 

You could print that data set as is, since any format applied to DEACTDT would remain unchanged.

 

To get your original format attempt to work, you could try:

 

proc format;

value ndate

. = '01/20/2001'

other = [mmddyyS10.];

run;

 

I can't test this until Monday, but that should work.  Note that the S in the format name indicates that the separator between parts of the date should be a slash.  (There are alternatives.)

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19
Can you post the log?
Astounding
PROC Star

It's not clear whether you are pursuing the proper path or not.  A format changes what prints, but doesn't change the data values themselves.  If changing the data values is the goal, you could try:

 

data pipe_3;

set pipe_2;

if deactdt = . then deactdt = '20jan2001'd;

run;

 

You could print that data set as is, since any format applied to DEACTDT would remain unchanged.

 

To get your original format attempt to work, you could try:

 

proc format;

value ndate

. = '01/20/2001'

other = [mmddyyS10.];

run;

 

I can't test this until Monday, but that should work.  Note that the S in the format name indicates that the separator between parts of the date should be a slash.  (There are alternatives.)

Azhar_ca
Calcite | Level 5
astounding data step fixed my problem.

thanks a lot.
Have A Wonderful Day.

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
  • 6024 views
  • 0 likes
  • 3 in conversation