Checking if a all expected value are in a sas variable column and if not adding them automatically

Reply
Contributor Kc2
Contributor
Posts: 31

Checking if a all expected value are in a sas variable column and if not adding them automatically

Hello,

 

I am running a macro program to do a summary of  the parameters values at different time points per treatment.

The problem I run into is that all the treatments are not present at each time points.

Ex;

 

start data

       start time :

input

treatment    parameter1   parameter2   parameter3

1                  tall                high               normal

2                  small            high               abnormal

3                  average       low                 not done

4                 average        high                normal

5                 small            not done         abnormal

 

 

output:

 

                            _1      _2      _3      _4       _5

Parameter1

    tall                    2        1       1                 1

    small                                    2         2

    average                                1                  3

 

Parameter2

    high                           1          3

    low                 1                             2    

    not  done         1                                     4

 

Parameter3

   abnormal                              3                  4

   normal          2          1

   not done                                     2

 

Time point 72 hours

 

input

treatment    parameter1   parameter2   parameter3

1                  tall                high               normal

2                  small            high               abnormal

4                 average        high                normal

 

 

                            _1      _2      _3     

Parameter1

    tall                    2        1       1           

    small                                    2        

    average                                1 

 

Because not all treatments are present at each time point, the outputs generated by the macro are incorrect.

Is there a way to run a check at the input data level to make sure that all the treatment (1 to 5) are present and if not add them?

 

thanks

Grand Advisor
Posts: 17,333

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

You don't specify how your creating your tables, but you can use PROC TABULATE with PRELOADFMT option.

 

The various options are listed here:

http://www.lexjansen.com/nesug/nesug11/cc/cc29.pdf

 

 

Contributor Kc2
Contributor
Posts: 31

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

I start with an adam dataset and do proc transpose to get the data at the starting point  (basically swtiching the parameters from rows into column).

Super Contributor
Posts: 406

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

Hi @Kc2,

 

It is not clear how you create the report. But depending on that you have a few options:

 

1) Create a table with all treatments and left-joining that in SQL with your current data.

2) Some procs allow you to take the classification values from a format (I forgot where and how but trust me it's there somewhere)

3) Proc tabulate has a CLASSDATA statement that allows for a separate table with all values for a classification variable

4) ...

 

Hope this helps,

- Jan.

Super Contributor
Posts: 406

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

Ha @Reeza got it: PRELOADFMT. Nice.
Respected Advisor
Posts: 4,973

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

One more thing to look at ...

 

Have you examined the data (a simple PROC PRINT) before and after the transpose?  When transpose encounters missing values, it can shift data values.

Contributor Kc2
Contributor
Posts: 31

Re: Checking if a all expected value are in a sas variable column and if not adding them automatical

When I do look at the data I do see that the treatment variables are misisng in some visit. ISnce I run everything in the macro I want all the exceptions to be handled automatically.

 

%Macro start(tp=, pop=, trt=);

 

data in;

set analysisdt (where=(population=&pop.));

run;

 

proc sort dat=in, by subjid &trt. parameter aval;

 

proc transpose data=in out=transdt;

by subjid &trt. 

var aval;

id parameter ;

idlabel parameter ;

run;

 

%summcr(in=transdt, out=final);

 

%mend;

%Start(tp=0, pop=safety, trt=trtra);

%Start(tp=24, pop=safety, trt=trtra);

%Start(tp=48, pop=safety, trt=trtra);

%Start(tp=72, pop=safety, trt=trtra);

 

after the proc tranpose the Transdt data has all the treatment values for the time point 0   but not for  time point 72.

I want to add a codeat the transdt dataset level or before  to check if all the treatment values are present and if not add them and then put this data into the summcr macro to run the summarya dn generate the output file.

Ask a Question
Discussion stats
  • 6 replies
  • 343 views
  • 1 like
  • 4 in conversation