|Date: ||Tue, 23 Feb 2010 12:47:13 -0800|
|Reply-To: ||William Krause <wkrause2003@YAHOO.COM>|
|Sender: ||"SAS(r) Discussion" <SAS-L@LISTSERV.UGA.EDU>|
|From: ||William Krause <wkrause2003@YAHOO.COM>|
|Subject: ||Re: manipulating data in an obs|
|Content-Type: ||text/plain; charset=iso-8859-1|
The output is correct as listed below. The A data will be put in the v51-v100 variables in the order inputed but one after that other starting at V51.
The C data will be put in the V101-v150 variables in the order inputed except that it must be in the next corresponding variable in the V101-V150 variables as though the A data was put in there first.
The data come from a flat file or DB table or could be a SAS dataset.
It is assumed that the data is in the order as indicated. Only the first 50 variables will be populated. The other 100 variables will be defined but either blank or missing.
2. The will be 150 variables.
3. No that is the way the output is to be shown.
Thanks for the response.
--- On Tue, 2/23/10, Jack Clark <jclark@HILLTOP.UMBC.EDU> wrote:
From: Jack Clark <jclark@HILLTOP.UMBC.EDU>
Subject: Re: manipulating data in an obs
Date: Tuesday, February 23, 2010, 2:19 PM
A couple of questions...
1. Are you reading data from a flat file or is it already in a SAS data
2. Am I correct in understanding that you have a file (either flat file
or SAS data set) which has only 50 variables, and that you want to add
the other 100 variables?
3. It seems the sample data you provided for line 4 goes against your
description. I would think that the data for Patty would go in
V107-V109 instead of V110-V112 and that the data for Polo would go in
V60-V62 instead of V57-V59. Please verify if this was a typo, and if
not, please clarify the rule for assigning additional variables.
Senior Research Analyst
University of Maryland, Baltimore County
Sondheim Hall, 3rd Floor
1000 Hilltop Circle
Baltimore, MD 21250
Confidentiality Notice: This e-mail may contain information that is legally privileged and that is intended only for the use of the addressee(s) named above. If you are not the intended recipient, you are hereby notified that any disclosure, copying of this e-mail, distribution, or action taken in reliance on the contents of this e-mail and/or documents attributed to this e-mail is strictly prohibited. If you have received this information in error, please notify the sender immediately by phone and delete this entire e-mail. Thank you.-----Original Message-----
From: SAS(r) Discussion [mailto:SAS-L@LISTSERV.UGA.EDU] On Behalf Of
Sent: Tuesday, February 23, 2010 1:55 PM
Subject: manipulating data in an obs
I want to realign the data in each observation based on an initial
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
The first 50 variables determine whether a variable will be in the
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
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 ..
. . 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.