LISTSERV at the University of Georgia
Menubar Imagemap
Home Browse Manage Request Manuals Register
Previous messageNext messagePrevious in topicNext in topicPrevious by same authorNext by same authorPrevious page (February 2008, week 3)Back to main SAS-L pageJoin or leave SAS-L (or change settings)ReplyPost a new messageSearchProportional fontNon-proportional font
Date:         Tue, 19 Feb 2008 12:07:51 -0500
Reply-To:     "data _null_," <datanull@GMAIL.COM>
Sender:       "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From:         "data _null_," <datanull@GMAIL.COM>
Subject:      Re: Two indices with the same FORMAT
Comments: To: Stefan Pohl <stefan.pohl@ish.de>
In-Reply-To:  <DC0169F71031414DA1F74BCF7537ED44@aktuare.local>
Content-Type: text/plain; charset=ISO-8859-1

You need to create the new variables using the attributes of the old variable. One way is as follows.

data work.test; set sashelp.class; format height 7.2 weight 8.1; run; proc contents varnum; run;

data work.newTest; if 0 then set work.test(keep=height weight rename=(height=Height1 weight=Weight1)); call missing(Height1,Weight1); set work.test;

*statements to assign values to HEIGHT1 and WEIGHT1;

run; proc contents varnum; run;

On Feb 18, 2008 3:30 PM, Stefan Pohl <stefan.pohl@ish.de> wrote: > Dear sas-group, > > I have written a sas macro. I read in the data set > > DATA test; > SET test_old; > FORMAT x COMMAX15.2 y 15.5; > RUN; > > My macro looks like this: > > %macro bla (x,y) > > DATA table3_&data&i; > SET table2_&data&i; > FORMAT y1 15.5 x1 COMMAX15.2; <-- I want to avoid the format > statements for y1 and x1 here in the macro, because the > formats depend on the input data > set!!! > > IF ... THEN DO; > x1=Lag(&x)+&x; > ... > END; > ... > > RUN; > > * Later in the macro I replace x1 with x and y1 with y; > > DATA end_&data&i (KEEP=x1 y1 RENAME=(x1=&x y1=&y)); > > ... > > %mend bla > > But x nor y have the previous set format if I do not write the format > statements for x1 and y1 explicitly inside the macro. > > > Best regards, Stefan. > > > > -----Ursprüngliche Nachricht----- > > Von: Nathaniel.Wooding@dom.com [mailto:Nathaniel.Wooding@dom.com] > > Gesendet: Montag, 18. Februar 2008 20:56 > > An: Stefan Pohl > > Cc: SAS-L@LISTSERV.UGA.EDU > > Betreff: Re: Two indices with the same FORMAT > > > > > Stefan > > > > You may change the format as often as you like by using a > > Format statement. > > I assume that when the data set was created, formats were > > given for each index and that if you run a proc contents or > > look at the data set with the SAS explorer window, you will > > see the 15.2 format next to each variable. If you are running > > a new data step and want to change the format, you can write > > > > Format index2 10.4 ; or whatever suitable format you > > desire. You do > > not have to refer to the other index in the Format statement. > > Note that this changes the format for this and any subsequent > > data steps in the current session. You could also use the > > format statement after a Proc such as Proc Print > > > > Proc print; > > format index2 7.5 ; > > run; > > > > and the format would NOT be changed in the data set. > > > > Aren't you at work a bit late in the evening? > > > > Nat Wooding > > Environmental Specialist III > > Dominion, Environmental Biology > > 4111 Castlewood Rd > > Richmond, VA 23234 > > Phone:804-271-5313, Fax: 804-271-2977 > > > > > > > > > > Stefan Pohl > > > > <stefan.pohl@ISH. > > > > DE> > > To > > Sent by: "SAS(r) SAS-L@LISTSERV.UGA.EDU > > > > Discussion" > > cc > > <SAS-L@LISTSERV.U > > > > GA.EDU> > > Subject > > Two indices with the > > same FORMAT > > > > > > 02/18/2008 02:40 > > > > PM > > > > > > > > > > > > Please respond to > > > > Stefan Pohl > > > > <stefan.pohl@ISH. > > > > DE> > > > > > > > > > > > > > > > > > > > > Hi sas-group, > > > > I have an ndex which is formatted 15.5. I have a second > > index2 which has the same format as index, but I don't want > > to write index2 15.5. > > > > Is it possible to write something like FORMAT index2= FORMAT index? > > > > Best regards, Stefan. > > > > > > > > ----------------------------------------- > > CONFIDENTIALITY NOTICE: This electronic message contains > > information which may be legally confidential and/or > > privileged and does not in any case represent a firm ENERGY > > COMMODITY bid or offer relating thereto which binds the > > sender without an additional express written confirmation to > > that effect. The information is intended solely for the > > individual or entity named above and access by anyone else is > > unauthorized. If you are not the intended recipient, any > > disclosure, copying, distribution, or use of the contents of > > this information is prohibited and may be unlawful. If you > > have received this electronic transmission in error, please > > reply immediately to the sender that you have received the > > message in error, and delete it. Thank you. > > > > __________ NOD32 2883 (20080218) Information __________ > > > > This message was checked by NOD32 antivirus system. > > http://www.eset.com > > > > >


Back to: Top of message | Previous page | Main SAS-L page