Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine Observations 1

Status
Not open for further replies.

stats777

Technical User
Feb 10, 2009
6
US
Hi

Below is the data which consist of IDs (SLEGEN1, 2 and 3) and their respective observations (ie. 4 2 2 2 1 1 1 4 4…etc for the first ID and such. The observations are arranged horizontally and continued in the next row until the end)

/* data */
SLEGEN1 4 2 2 2 1 1 4 4 3 3 1 1 1 1 1 3 2 2 3 3 2 2 4 4 1 1 4 4 1 1 2 2 2 2 1 1 4 4 2 2 2 2 1 1 2 2 2 2 4 4 1 2 4 2 3 3 4 4 1 3 4 4 2 2 4 2 2 2 0 0 3 3 4 2 4 2 3 3 4 4 2 2 4 2 1 3 4 4 4 2 1 1 4 4 3 3 2 2 1 2 2 2 3 3 2 2 1 3 4
SLEGEN2 0 0 2 2 1 1 4 4 3 3 1 1 1 3 1 3 2 2 3 3 4 2 4 2 1 1 4 4 1 1 2 2 2 2 1 1 4 4 2 2 4 2 1 1 2 2 4 2 4 2 1 2 4 2 3 3 4 4 1 3 4 2 1 2 4 4 4 2 2 2 1 3 2 2 2 2 1 3 4 3 4 2 4 4 1 3 4 4 4 2 1 3 4 3 3 3 4 4 2 2 2 2 1 3 2 2 3 3 3
SLEGEN3 4 4 2 2 1 1 4 4 0 0 1 1 1 1 1 1 2 2 1 3 4 2 4 4 3 3 4 4 3 3 2 2 4 4 1 1 4 4 4 4 2 2 1 1 2 2 2 2 4 2 1 2 4 2 3 3 4 4 3 3 2 2 1 1 4 2 4 2 1 2 3 3 4 2 4 2 3 3 4 4 2 2 4 2 1 1 4 4 4 4 1 1 3 3 3 3 4 4 2 2 2 2 1 1 2 2 3 3 3


Now I need to combined the observations such that 4 2 2 2 1 1 1 4 4..etc will become 4 2 as one observation, 2 2 as another observation. Like 1st and 2nd , 3rd and 4th , 5th and 6th ..etc.

Next is to assess the observations, for example if the observation is 4 2, give it a ‘1’. If it is 2 2, then give it a ‘2’. , 1 3 -> '1'

I managed to read in the data by the data step as follow but I still couldnt combine the observation as mentioned above.

options ps=80 ls=66 nonumber nodate;
data chr22;
infile c dlm='' lrecl=32764;
input ID $ @;
DO i=1 to 11010;
input allele @;
output;
end;
run;

Appreciate if some experts could help!
Thanks =]
J




 
Perhaps something like this? Adding every second record to 10*first record.

If you prefer this as a string, you can concatenate every second record to the first.

HTH

Code:
data chr22;
retain double;
infile c dlm='' lrecl=32764;
input ID $ @;
DO i=1 to 11010;
    input allele @;
    if mod(i,2) then double = 10*allele ;
    else do;
       double ++ allele;
       /* Create categories here */
       if double = 42 or double > 13 then cat = 1;
       else if double = 22 then cat = 2;
       else cat =99999; * What to do with unhandled categories ?
       /* End of category code */
       output;
       end;
    end;
run;
 
Just noticed, no need for the retain statement in this example as the sum statement is being used.
 
Thanks so much HTH,

regarding unhandled observations.. I would like to check every two digit in all observation such that if the two digits
are identical give it a "2" (ie. all 11, 22, 33, 44, and 00 will have '2')
if they are different (ie. 13, 21, 24. 43...and all other possible combination) give it '1'. How do I go about that? Thanks.

J
 
a little more explanation for my problem. For example SLEGEN1 is

SLEGEN1 4 2 2 2 1 1 4 4 3 3 1 1 1 1 1 3 2 2 3 3 2 2 4 4 1 1 4 4 1 1 ....

I'd like to group the observations such that

SLEGEN1 42 22 11 44 22 33 11 11 13 22 33 22 44 11 ....

(the total number of observations for each ID will be halved)

The assign a score

SLEGEN1 1 2 2 2 2 2 2 2 1 2 2 2 2 2.....

thanks!!
 
I was told by some cool kids that HTH stands for Hope That Helps. Maybe they told me a porky :(

We can make use of a few power of 10 tricks to get our answers.

Hope That Helps :)

Code:
if mod(double,10) = int(double/10) then cat = 2 ;
else cat = 1 ;
 
haha thanks once again kdt82! you are smart.
I am a programming dumb.. just wonder how to be as clever as you in SAS.. :)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top