Mofify data values of n's variables

Mofify data values of n's variables

Post by marcioesta » Fri, 29 Sep 2006 22:59:59


<p>Hey all,</p><p>I have a dataset with a big number of variables that I =
have the
same results YES/NO/MISSING and I am planning to modify th=
e data
value and put a format on them to get what I want. I could do this utiliz=
ing IF
THEN, but they're a lot of variables.</p><p>As I said my variables are ch=
aracter
and I want to replace YES into 1, NO into 2 and MISSING into 3, then I co=
uld use
some kind of format on these variables as 1 into YES, 2 into NO and 3 int=
o NO
RESPONSE. I made some research on PROC SQL ALTER TABLE/UPDATE, but I did =
not make
it. Any suggestions?</p><p>Thanks in advance,</p><p>Márcio</p><p>&=
nbsp;</p>
 
 
 

Mofify data values of n's variables

Post by tobydun » Fri, 29 Sep 2006 23:09:32

Marcio ,

Call me crazy but why dont you skip to just formtting the YES/NO/MISSING to
YES/NO/NO RESPONSE?


Proc Format ;
Value $NewRecode
'MISSING' = 'NO RESPONSE' ;
Run ;

Should do it.


Toby Dunn

When everything is coming at you all at once, your in the wrong lane.

A truly happy person is someone who can smile and enjoy the scenery on a
detour.





From: " XXXX@XXXXX.COM " < XXXX@XXXXX.COM >
Reply-To: " XXXX@XXXXX.COM " < XXXX@XXXXX.COM >
To: XXXX@XXXXX.COM
Subject: Mofify data values of n's variables
Date: Thu, 28 Sep 2006 10:59:59 -0300


Hey all,
I have a dataset with a big number of variables that I have the
same results YES/NO/MISSING and I am planning to modify the data
value and put a format on them to get what I want. I could do this utilizing
IF
THEN, but they're a lot of variables.
As I said my variables are character
and I want to replace YES into 1, NO into 2 and MISSING into 3, then I could
use
some kind of format on these variables as 1 into YES, 2 into NO and 3 into
NO
RESPONSE. I made some research on PROC SQL ALTER TABLE/UPDATE, but I did not
make
it. Any suggestions?
Thanks in advance,
Mcio

 
 
 

Mofify data values of n's variables

Post by nospa » Sat, 30 Sep 2006 02:08:10

On Thu, 28 Sep 2006 10:59:59 -0300, XXXX@XXXXX.COM


Hey all,
I have a dataset with a big number of variables that I have the
same results YES/NO/MISSING and I am planning to modify the data
value and put a format on them to get what I want. I could do this utilizing
IF
THEN, but they're a lot of variables.
As I said my variables are character
and I want to replace YES into 1, NO into 2 and MISSING into 3, then I could
use
some kind of format on these variables as 1 into YES, 2 into NO and 3 into
NO
RESPONSE. I made some research on PROC SQL ALTER TABLE/UPDATE, but I did not
make
it. Any suggestions?

Create an informat and use it with the INPUT function to map "YES" to "1"
etc. Also create a format to do the reverse, but use it only for reporting
and displaying.

Thanks in advance,
Mcio
 
 
 

Mofify data values of n's variables

Post by marcioesta » Sat, 30 Sep 2006 22:09:14

lt;pre>Hey Toby and listers,</pre><pre>I found out how to modify a group of=
variables
values,</pre><pre>using ARRAY with the code below. But I am now searching
if is there a was to set a format for the label,</pre><pre=
I want to get 1 into YES, 2 into NO and 3 into BLANK for all va=
riables of
my dataset. Do you have any idea?</pre><pre>Remenber that I have alm=
ost 100
variables and if I use PROC FORMAT, the code will be not
functional.</pre><pre>Thanks,</pre><pre>Márcio </pre><pre>dat=
a
lib.fix(drop=3Di);</pre><pre>set lib.fix;</pre><pre>array fix(1:10) PA101=
01 PA10102
PA10103 PA10104 PA10201 PA10202 PA10203 PA10204 PA10205 PA10301;</pre><pr=
e>do i=3D1
to 10;</pre><pre>if fix(i)=3D's' then fix(i)=3D'1';</pre><pre>end;</pre><=
pre>do i=3D1 to
10;</pre><pre>if fix(i)=3D'n' then fix(i)=3D'2';</pre><pre>end;</pre><pre=
10;</pre><pre>if fix(i)=3D' ' then
fix(i)=3D'3';</pre><pre>end;</pre><pre>run;</pre><p><br
/>-----------------------------------------------------------------------=
---------<br
/>Depends on how they are named, if there is some commonality to them you=
can <br
/>always hit the dictionary.columns table and grab them, otherwise no mat=
ter <br
/>what any one comes up with you are stuck writing them out by hand.<br /=
/><br />Toby Dunn<br /><br />When everything is coming at you all at once=
, your in
the wrong lane.<br /><br />A truly happy person is someone who can smile =
and enjoy
the scenery on a <br />detour.<br /><br /><br /><br /><br /><br />From:
" XXXX@XXXXX.COM " To: "toby dunn" Subject: Re:=
Mofify
data values of n's variables<br />Date: Thu, 28 Sep 2006 15:23:12 -0300 (=
EST)<br
/><br /><br />Hey Toby,<br />I got what you did, but the problem is that =
I have
about 100<br />variables. So, I would need to do the proc format for 100 =
variables.
Do you <br />know if<br />is there a way to apply the same proc format to=
a group
of<br />variables?<br />Thanks,<br />Márcio<br /><br
/>-----------------------------------------------------------------------=
---------<br
/>Marcio ,<br /><br />Call me crazy but why dont you skip to just formtti=
ng the<br
/>YES/NO/MISSING to<br />YES/NO/NO RESPONSE?<br /><br /><br />Proc Format=
;<br
/>Value $NewRecode<br />'MISSING' =3D 'NO RESPONSE' ;<br />Run ;<br /><br=
/>Should
do<br />it.<br /><br /><br />Toby Dunn<br /><br />When everything is comi=
ng at you
all at<br />once, your in the wrong lane.<br /><br />A truly happy person=
is
someone who can<br />smile and enjoy the scenery on a<br />detour.<br /><=
br /><br
/><br /><br /><br />From: " XXXX@XXXXX.COM " Reply-To:<br
/>" XXXX@XXXXX.COM " To: XXXX@XXXXX.COM <br />Subj=
ect:
Mofify<br />data values of n's variables<br />Date: Thu, 28 Sep 2006 10:5=
9:59
-
 
 
 

Mofify data values of n's variables

Post by nospa » Mon, 02 Oct 2006 11:35:19

Why is using PROC FORMAT "not functional"? All it takes is something like

proc format;
value $myfmt "1"="YES" "2"="NO" "3"="BLANK";
quit;

then later

format PA : $myfmt.;

In your code as shown below, you could use one DO loop instead of 3, and if
you used PROC FORMAT to build an informat, you could avoid all of the IF
statements (though it's not a big deal if there are only 3 of them).

On Fri, 29 Sep 2006 10:09:14 -0300, XXXX@XXXXX.COM


Hey Toby and listers,

I found out how to modify a group of variables values, using ARRAY with the
code below. But I am now searching if is there a was to set a format for the
label, because I want to get 1 into YES, 2 into NO and 3 into BLANK for all
variables of my dataset. Do you have any idea?

Remenber that I have almost 100 variables and if I use PROC FORMAT, the code
will be not functional.

Thanks,

Mcio
;
data lib.fix(drop=i);

set lib.fix;

array fix(1:10) PA10101 PA10102 PA10103 PA10104 PA10201 PA10202 PA10203
PA10204 PA10205 PA10301;

do i=1 to 10;

if fix(i)='s' then fix(i)='1';

end;

do i=1 to 10;

if fix(i)='n' then fix(i)='2';

end;

do i=1 to 10;

if fix(i)=' ' then fix(i)='3';

end;

run;