02-01-2015 06:05 AM
In general no, but if you're trying to dynamically recode a variable take a look at putC and putN functions which take an argument as the second parameter. However, they will be character variables reflecting the formatted variables not the underlying variables.
A variable can have only one format assigned so if the entire variable is taking a different format in different circumstances then you can use macro logic.
02-01-2015 07:07 AM
Thanks alot for your replies,
Could you explain me, macro logic taking sashelp.class writing condition on sex and formatting the values of height with two different formats.
02-01-2015 07:47 AM
You can't have two separate formats for one variable within one data step/procedure.
By using macro logic you can dynamically chose the format depending on a specified condition (%IF - see on-line doc, or take some training/tutorial).
If you for some reason what to chose a format on an observation level you might want to examine your whole report/data management process (or even you data model).
02-01-2015 08:33 PM
What you want to do is possible with PROC REPORT, but not possible with a data. A dataset can only have 1 format applied to a variable column. But, a REPORT can have different formats applied to different report rows using CALL DEFINE. See the code below as an example. Note that this will impact what you see on each report row, but does not impact how the data is stored internally.
proc report data=sashelp.class nowd;
column name age sex height weight;
define name / order;
define age / display;
define sex / display;
define height / display;
define weight / display;
if name = 'Alfred' then
else if substr(name,1,1) = 'J' and sex = 'F' then
else call define(_col_,'format','12.0');
02-02-2015 02:33 AM
I am writing sas strored process to bring data from sas olap cube and writes to the _webout, The strored process has measure parmeter , based on measure selection the strored process brings the data from cube. I have controll table which has list of measures and formats to the repective measures in seperate colums. My requirement is based on the measure slection the related measure format is applied and writes to the _webout(this is beacuse the client wants to controll formats from control table)
parmeter value can be passed for single, double and triple measures from the control table.
productname measure 2005 2006 2007
a price 25 25 25
a quantity 10 20 5
a totalsale 250 500 125
b price 30 30 30
b quantity 10 20 30
b totalsale 300 600 900
c price 40 40 40
c quantity 10 20 5
c totalsale 400 800 200
02-02-2015 03:49 AM
Building a stored process makes this task probably a bit more difficult. Why not use an OLAP viewer and use the cube formats?
If you endure with a data set based solution, you need to put the value using a specied format, and store the result in a char column. Doable, but not good looking...
02-02-2015 05:06 AM
Yes, I agree with olap viewer and cube formats in my case stored process deployed as soap webservice to use it in java applications for presentation.
Hence I cann't use the above given procedures also.
02-02-2015 05:29 AM
Then I suggest that you deliver the data extract in normalized format, and let the GUI people handle the lay-out.
Use the principles of layered architecture.
02-02-2015 07:28 AM
The problem is with how your storing thr data. Which isn't conducive to updates either.
Try putting your variables (sales, quantity, total sales) as columns and years as rows