Date: Mon, 10 Apr 2006 16:38:42 -0400
Reply-To: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: "Rickards, Clinton (GE Consumer Finance)"
<clinton.rickards@GE.COM>
Subject: Re: Two level format name, possible? (thanks and my solution)
In-Reply-To: A<C0C8366F844D9F448DF6A5E40A1C2B9E61A502@A-EXCH2K3-VS2.amylin.com>
Content-Type: text/plain; charset="iso-8859-1"
Ya,
I think you can get away with only 2 proc catalogs. assuming v1.formats is in your format search path, format visit can be used as is to handle visit 1:
proc catalog catalog=v1.formats;
copy out=work.formats et=format;
select visit;
run;
proc catalog catalog=work.formats;
change visit=v2sit / et=format;
run;
data visit;
set visit;
if study=1 then cvisit=put(visit,visit.);
else if study=2 then cvisit=put(visit,v2sit.);
run;
Clint
-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU]On Behalf Of
Huang, Ya
Sent: Monday, April 10, 2006 3:54 PM
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Two level format name, possible? (thanks and my solution)
Thanks everyone for response.
The key to solve this problem is to create two formats, or better yet
rename the formats so that they can have different names. Copy/past
to recreate the format is not acceptable, assuming the source code is
not available. cntlin/cntlout is not my favorite either. I thought about
proc catalog, but never try it. Since everybody says it is not possible
to do two level name referencing, I decided to give catalog a try. The following
is what I come up, and it seems to work fine:
proc catalog catalog=v1.formats;
copy out=work.formats et=format;
select visit;
run;
proc catalog catalog=work.formats;
change visit=v1sit / et=format;
run;
proc catalog catalog=v2.formats;
copy out=work.formats et=format;
select visit;
run;
proc catalog catalog=work.formats;
change visit=v2sit / et=format;
run;
data visit;
set visit;
if study=1 then cvisit=put(visit,v1sit.);
else if study=2 then cvisit=put(visit,v2sit.);
run;
Above code can be easily macronized. Of course, putn can be
helpful in the last data step too. I was hoping that one
proc catalog can do the copy and renaming, but I have to
use two.
Thanks
Ya
-----Original Message-----
From: toby dunn [mailto:tobydunn@hotmail.com]
Sent: Monday, April 10, 2006 12:05 PM
To: Huang, Ya; SAS-L@LISTSERV.UGA.EDU
Subject: Re: Two level format name, possible?
Ya ,
Since my SAS Server is still down and I have nothing better to do with my
time than ponder SAS-L posts so let me make this observations. Given your
name collision problem with the formats you have two choices: 1.) redo your
format names, in which case not much of a problem. I would use PutN (Howard
makes a good point here) and create the format name on the fly. or 2.) Read
your formats into SAS and then combine them there in what ever fashion you
deem desirable. Again I would do something where I could create the format
names on the fly. PutN alone and no amount of nesting formats is directly
gonna solve your problem.
Toby Dunn
From: Ya Huang <ya.huang@AMYLIN.COM>
Reply-To: Ya Huang <ya.huang@AMYLIN.COM>
To: SAS-L@LISTSERV.UGA.EDU
Subject: Re: Two level format name, possible?
Date: Mon, 10 Apr 2006 12:11:45 -0400
Sorry, these two lines were left out in my previous post:
libname v1 "c:\temp\v1";
libname v2 "c:\temp\v2";
On Mon, 10 Apr 2006 12:09:54 -0400, Ya Huang <ya.huang@AMYLIN.COM> wrote:
>Hi there,
>
>Assuming that I have two formats catalog stored in two different place,
>and the format names are same. Is there any way I can use them in one
>data step with some kind two level name reference? I search the SAS-L
>archive, and found one very old thread (10 year ago) which basically
>concluded that no easy way to do this. I wonder if this has been changed
>with all the later version of SAS:
>
>proc format library=v1;
>value visit
>1='Day -7'
>2='Week 1'
>3='Week 4'
>;
>
>proc format library=v2;
>value visit
>1='Day -7'
>2='Week 1'
>3='Week 6'
>;
>
>data visit;
>study=1; visit=1; output;
>study=1; visit=2; output;
>study=1; visit=3; output;
>study=2; visit=1; output;
>study=2; visit=2; output;
>study=2; visit=3; output;
>run;
>
>** this doesn't work;
>data visit;
> set visit;
>if study=1 then cvisit=put(visit,v1.visit.);
>else if study=2 then cvisit=put(visit,v2.visit.);
>run;
>
>
>Thanks
>
>Ya