Date: Tue, 23 Feb 2010 13:54:53 -0500
Reply-To: William Krause <wkrause2003@YAHOO.COM>
Sender: "SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>
From: William Krause <wkrause2003@YAHOO.COM>
Subject: manipulating data in an obs
I want to realign the data in each observation based on an initial section
of variables.
I have 150 variables which are character or numeric.
So a character - var1 would have a corresponding var51 and var101.
If var4 was numeric then the corresponding var54 and var104 would be
numeric.
The first 50 variables determine whether a variable will be in the second
50 variables or the third fifty variables.
My input is the makeup of a family.
The first fifty variables contain the family info (section1).
The second contain only the adult info (section2).
The third fifty variables contains only the child info (section3)
Input is person idenifier as A for Adult and C for Child.
Also included in their name and age.
data family ;
infile datalines missover ;
Input v1 $1. v2 $ v3 v4 $1. v4 $ v6
v7 $1. v8 $ v9 v10 $1. v11 $ v12
etc.... ;
datalines ;
A John 35 A Jane 35 C Jim 3
A Sam 41 C Spike 14 A Sara 41 C Steve 4
C Bill 2 A Betty 25 A Bruno 27
A Pete 52 A Paula 51 C Patty 15 A Polo 22
;
Output should be as follows:
v1 v2 v3 v4 v5 v6 v7 v8 v9 v10 v11 v12 etc... v50
A John 35 A Jane 35 C Jim 3 .
A Sam 41 A Sara 41 C Spike 14 C Steve 4
A Betty 25 A Bruno 27 C Bill 2 .
A Pete 52 A Paula 51 C Patty 15 A Polo 22
v51 v52 v53 v54 v55 v56 v57 v58 v59 v60 v61 v62 etc .. v100
A John 35 A Jane 35 . .
A Sam 41 A Sara 41 . .
A Betty 25 A Bruno 27 . .
A Pete 52 A Paula 51 A Polo 22 .
v101 v102 v103 v104 v105 v106 v107 v108 v109 v110 v111 v112 etc .. v150
. . C Jim 3
. . C Spike 14 C Steve 4
. . C Bill 2 .
. . . C Patty 15
The A info must be moved to the section2.
The C info must to moved to the section3.
The locations of the data in the section2 and section3 are essential.
Any code solutions.
Thanks in advance for the assistance.
Bill K.