12-30-2013 08:19 AM
I was trying to run the following put in a data step
length formattoapply $20;
input formattoapply $;
newdate = put (today(), formattoapply);
where formattoapply is a column of b that should contains differents formats for differents rows.
If I run this, I get ERROR 85-322: Expecting a format name.
Do there is a way to apply a different format for different rows where the format to apply is contained in a column?
12-31-2013 06:38 AM
Based on my knowledge, it is not possible to apply multiple format to different rows for variable...You can read the variable containing different dates structure as charcter variable and can fix it as charcter variable...
However, it will be good if you can share the purpose of your analysis by using this date variable in subsequent step...
Usually, variable types creates conflict in appending and joining (merging) SAS Datasets...
If your aim is structurize the same dates for all the rows then need to think out of box!!!
12-31-2013 08:54 AM
In a report (as opposed to a table), you can apply different formats to data cells on a report row using PROC REPORT and CALL DEFINE.
ods html file='c:\temp\diff_fmt.html';
proc report data=sashelp.class nowd;
column name age sex ;
define name / order;
define age / display f=6.0;
define sex / display;
if name in ('Alfred', 'Alice', 'James') then do;
ods html close;
12-31-2013 02:36 PM
i have a couple of questions?
Is call define used only in the compute block ????
it can eithwer be _col_ or _row_ in the call define..........cannot be both at the same time right?
12-31-2013 09:49 PM
There are some situations (such as changing background color) that are appropriate for a _row_; however, it would not be appropriate to use _row_ for a format, when the report row contains both character and numeric variables...a numeric format cannot be used with a character variable.
The doc on CALL DEFINE is quite clear that you can have something other than _col_ or _row_, you can used a named variable, an absolute column number, and even an expression that resolves to a variable name. A CALL DEFINE statement can only be used in a COMPUTE block and only with PROC REPORT (not PRINT, not TABULATE).
01-02-2014 01:51 AM
We can apply multiple formats for a single variable as required. I faced this in my previous project to create multiple formats for each row.
You can see the attachment which i have created with multiple formats using Proc Report and call define as Cynthia said.