- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
I was trying to run the following put in a data step
data b;
length formattoapply $20;
input formattoapply $;
cards;
YYMMN4.
date9.
datetime20.
;
run;
data a;
set b;
newdate = put (today(), formattoapply);
run;
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?
many thanks.
regards
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
that would the putN function in this case.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
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!!!
-Urvish
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
HI:
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.
Cynthia
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;
compute age;
if name in ('Alfred', 'Alice', 'James') then do;
call define(_col_,'format','9.3');
call define(_col_,'style','style={background=yellow}');
end;
endcomp;
run;
ods html close;
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi Cynthia,
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?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you could take Cynthia's example and experiment. Add a call define(_row_ and see what happens.
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi:
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).
cynthia
- Mark as New
- Bookmark
- Subscribe
- Mute
- RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
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.
Thanks,
Vishnu