Hi...
I am having the following code
data xx;
input folder $ date ddmmyy10.;
format date ddmmyy10.;
cards;
week1 21/05/2012
week2 21/05/2011
week3 21/05/2010
;
run;
data yy;
set xx;
format week1 week2 week3 date9.;
if folder = 'week1' then week1 = date;
if folder = 'week2' then week2 = date;
if folder = 'week3' then week3 = date;
run;
I want to display ' '(space) in the place of ' . '(period) , whenever the date is missing the Week1,week2,week3 columns .
Note:I don't want to use any IF conditions.
Thanks in advance ..
Regards,
Sanjeev.K
Hi Sanjeev,
You could try using the following options statement before your code:
options missing=' ';
I wasn't sure if you wanted to replace your if statements as you noted, but if that is the case then you could use the select statement.
Regards,
Amir.
Hi Amir..
IF i use Missing='' option,other numeric variables(which are not shown in the code) also effected.but i want to keep periods in numeric variables when there is no data.
Thanks..
Sanjeev.K
Hi Sanjeev,
I'm not sure how some numeric data can have missing represented by a blank and others be represented by a period at the same time
Perhaps consider using some default value which is not going to appear in your input data.
I did find this forum question https://communities.sas.com/message/139151#139151 but was unable to get the solution to fit around your problem.
Regards,
Amir.
Message was edited by: Amir Malik - rephrase.
To avoid your if-statements, use PROC TRANSPOSE.
I think as Amir it's hard to have different missing chars in he same report.
perhaps (untested!) you can create a new format based on ddmmyy, where you explicitly set the missing to space...?
Another easier option is to convert your date columns to char prior to reporting, and then replace . with space.
Could you please provide what option is there.
Thanks & Regards,
Yaswanth J.
Hi LinusH..
Did't get you completely...
Can you please write sample code for my above example.??
That make sense..
Thanks..
Sanjeev.K
If you report directly from your import data, use char informat directly:
input $date char10.;
The there will never be a period (unless your source data contains it...)
PROC TRANSPOSE, see online doc, stuffed with examples...
If there is not a very good reason then I wouldn't store dates as strings but as SAS date values. If you're using strings then one of the issues you're facing in reports is the sort order of the dates in your reports.
I believe using a user defined format as posted earlier will cover the requirement without causing new issues.
You could create your own format based on an existing one like done in below code:
proc format;
value My_ddmmyy
.=' '
other=[ddmmyy.]
;
run;
data have;
input folder $ date ddmmyy10.;
format date My_ddmmyy10.;
cards;
week1 21/05/2012
week2
week3 21/05/2010
;
run;
Patrick's response is a very good idea in general. When only one or two values need special appearance make a custom version of the format like this. It can save a great deal of complex coding.
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.