DATA Step, Macro, Functions and more

transpose

Reply
Occasional Contributor
Posts: 5

transpose

Hi,

I need your help please.

 

I have this data set:

PATIENT ID   EVENT ID    TEST    RESULT     TEST SITE

1212              10002            NAATP        P        PHARYNGEAL

1212              10002            NAATR        N        RECTUM

1212              10002             HIV             N         BLOOD

1110               10003            NAATP        P          PHARYNGEAL

1110               10003            NAATP        P          PHARYNGEAL

1212              10004            NAATR        N        RECTUM

1212              10004             HIV             N         BLOOD

1110               10005            NAATP        P          PHARYNGEAL

1110               10005            NAATP        P          PHARYNGEAL

 

 

 And I want to flip this data set like this BY UNIQUE PATIENT AND HAVE THE TEST IN SEPARATE CATEGORIES

PATIENT ID   EVENT ID    NAATP     NAATR 

1212              10002            P                 N

 

 And I want to flip this data set like this BY EVENT ID

 

I NEED TO BE ABLE TO ANALYZE THE DATA BY PATIENT WHAT KIND OF TEST DONE AND THE TEST RESULT OF EACH TEST

AND I WANT TO BE ABLE TO ANALYZE BY EVENT ID  WHAT KIND OF TEST DONE AT THAT EVENT AND THE TEST RESULT OF EACH TEST

Super User
Posts: 9,890

Re: transpose

In proc transpose, use

by patient_id event_id;

id test;

var result;

---------------------------------------------------------------------------------------------
Maxims of Maximally Efficient SAS Programmers
How to convert datasets to data steps
How to post code
Super User
Posts: 6,632

Re: transpose

How do you picture the results, for EVENT_ID 10003 and 10005?  There are two tests performed for each. But the way you designed the output, there is only one spot available to save two test results.

Occasional Contributor
Posts: 5

Re: transpose

Posted in reply to Astounding

I want to have all the tests and results of all tests. the out put I showed is just an example. 

Your help will be appreciated. 

Super User
Posts: 13,321

Re: transpose


@Dhana18 wrote:

Hi,

I need your help please.

 

I have this data set:

PATIENT ID   EVENT ID    TEST    RESULT     TEST SITE

1212              10002            NAATP        P        PHARYNGEAL

1212              10002            NAATR        N        RECTUM

1212              10002             HIV             N         BLOOD

1110               10003            NAATP        P          PHARYNGEAL

1110               10003            NAATP        P          PHARYNGEAL

1212              10004            NAATR        N        RECTUM

1212              10004             HIV             N         BLOOD

1110               10005            NAATP        P          PHARYNGEAL

1110               10005            NAATP        P          PHARYNGEAL

 

 

 And I want to flip this data set like this BY UNIQUE PATIENT AND HAVE THE TEST IN SEPARATE CATEGORIES

PATIENT ID   EVENT ID    NAATP     NAATR 

1212              10002            P                 N

 

 And I want to flip this data set like this BY EVENT ID

 

I NEED TO BE ABLE TO ANALYZE THE DATA BY PATIENT WHAT KIND OF TEST DONE AND THE TEST RESULT OF EACH TEST

AND I WANT TO BE ABLE TO ANALYZE BY EVENT ID  WHAT KIND OF TEST DONE AT THAT EVENT AND THE TEST RESULT OF EACH TEST


What type of analysis? Your data is already set up in a form that works for most analysis.

For instance this would count results within patient event test and testsite.

proc tabulate data=have;
   class patientid eventid test testsite result;
   table patientid *eventid * test* testsite,
         result * n
         /misstext=' ';
run;

Of course I have no actual idea what your variable names may be as you have not provided that information.

 

Ask a Question
Discussion stats
  • 4 replies
  • 66 views
  • 0 likes
  • 4 in conversation