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.
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.)
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.)
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!
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.