Is there a way to change the bands I have created via Proc Format to real values?
Ie I have a variable Price ranging from 1 - 100 and have used Proc Format to display it as A:1 - 10, B:10 - 20 etc
I want to merge this dataset to another one with the same format applied. Currently my merge wont match value 8 with format A:1 - 10 to value 7 wirth format A:1 - 10. Is there a way to make that happen?
Create your own SAS variable to use with the MERGE/BY processing - assign a SAS CHARACTER type variable using the SAS PUT function with your "source" variable a argument1 and the user SAS format name as argument2.
Suggested Google advanced search argument, this topic / post:
> Is there a way to change the bands I have created via
> Proc Format to real values?
> Ie I have a variable Price ranging from 1 - 100 and
> have used Proc Format to display it as A:1 - 10, B:10
> - 20 etc
> I want to merge this dataset to another one with the
> same format applied. Currently my merge wont match
> value 8 with format A:1 - 10 to value 7 wirth format
> A:1 - 10. Is there a way to make that happen?
First, if you attach a format to a variable, you are not changing the values at all, they just look different when displayed or printed out. You can create a new variable storing the formatted values of your original variable. Then you can use the new variable to further manage your data. Or you can just temporarily do that, if the execution efficiency is not your first priority. Here is one way using proc sql. hth.
/* test format and datasets */
value price 1-10="A" 10-20="B";
v1 = 1; price = 8; output;
v1 = 2; price = 13; output;
format price price.;
/* join one and two based on formatted price. notice
that you have to pass the format name as a literal in
calling the putn function */
create table three as
select v1, v2, one.price as price1,
two.price as price2 format = price.
from one, two
where putn(one.price, "price") = putn(two.price, "price");
/* check */
select * from three;
/* on lst
v1 v2 price1 price2
1 10 A A
2 20 B B
2 30 B B