Need coding help!

  • Follow


Hello-

I have a data set that have lists of names that recorded the person in
position each year. For a study, I need to create a column for each
year that records the years the person in that position. For example,
if Johnson Smith was in the position in the first year, I recorded 1;
the next year he was still there, so I gave 2. In the 3rd year, a new
person was in the position, so I started from 1.

ID	Last	      First	 Year1   Last	First	      Year2 	 Last
First	Year3
1	Smith    Johnson   1	   Smith	Johnson	2	Gardner	Sam	  1
2	Sneider  Mike	    1	   Sneider	Mike	        2	Sneider	Mike	  3
3	Clark	    Jennifer	    1	   White	Joan	        1	White	Joan	  2
4	Green    Mark	    1	   Geen 	Mark		2       Carlson	Aaron  1

The data set above is an example.

Since I have a large list for about 20 years, I wonder if there is a
way to code this procedure in SAS so that this can be done
efficiently.

Thank you,
Sandra
0
Reply Sandra 3/21/2011 8:13:31 PM

On Mar 21, 4:13=A0pm, Sandra <zhshen...@gmail.com> wrote:
> Hello-
>
> I have a data set that have lists of names that recorded the person in
> position each year. For a study, I need to create a column for each
> year that records the years the person in that position. For example,
> if Johnson Smith was in the position in the first year, I recorded 1;
> the next year he was still there, so I gave 2. In the 3rd year, a new
> person was in the position, so I started from 1.
>
> ID =A0 =A0 =A0Last =A0 =A0 =A0 =A0 =A0First =A0 =A0 =A0Year1 =A0 Last =A0=
 First =A0 =A0 =A0 =A0 Year2 =A0 =A0 =A0Last
> First =A0 Year3
> 1 =A0 =A0 =A0 Smith =A0 =A0Johnson =A0 1 =A0 =A0 =A0 Smith =A0 =A0 =A0 =
=A0Johnson 2 =A0 =A0 =A0 Gardner Sam =A0 =A0 =A0 1
> 2 =A0 =A0 =A0 Sneider =A0Mike =A0 =A0 =A0 1 =A0 =A0 =A0Sneider =A0 =A0 =
=A0Mike =A0 =A0 =A0 =A0 =A0 =A02 =A0 =A0 =A0 Sneider Mike =A0 =A0 =A03
> 3 =A0 =A0 =A0 Clark =A0 =A0 =A0 Jennifer =A0 =A0 =A0 =A01 =A0 =A0 =A0Whit=
e =A0 =A0 =A0 =A0Joan =A0 =A0 =A0 =A0 =A0 =A01 =A0 =A0 =A0 White =A0 Joan =
=A0 =A0 =A02
> 4 =A0 =A0 =A0 Green =A0 =A0Mark =A0 =A0 =A0 1 =A0 =A0 =A0Geen =A0 =A0 =A0=
 =A0 Mark =A0 =A0 =A0 =A0 =A0 =A02 =A0 =A0 =A0 Carlson Aaron =A01
>
> The data set above is an example.
>
> Since I have a large list for about 20 years, I wonder if there is a
> way to code this procedure in SAS so that this can be done
> efficiently.
>
> Thank you,
> Sandra

Look up the term Data Normalization and reconsider your proposed data
organizational structure.  It will prove to be unwieldy and completely
unmanageable.  Also do you realize that you have posted this question
to an SPSS list asking for SAS code ;-)
0
Reply David 3/22/2011 10:05:46 AM


1 Replies
157 Views

(page loaded in 0.301 seconds)

Similiar Articles:













7/29/2012 11:59:47 PM


Reply: