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.)
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.