ODS and Base Reporting

Build reports by using ODS to create HTML, PDF, RTF, Excel, text reports and more!
BookmarkSubscribeRSS Feed
HBa
Fluorite | Level 6 HBa
Fluorite | Level 6

i have a macro to run a series of proc mixed on a data base. it basically run the proc mixed on all columns so that i will gain a general idea about the data. when it runs, i like it to create a table as the output, where it reports independent and dependent variables as well as the p values. the macro is attached.

 

the output table looks like the following:

 

The SAS System         
          
ObsClassLevelsValuesDescrValueNumDFDenDFFValueProbF
1idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  ....
2fact2NOEC NOEO  ....
3REPT31 2 3  ....
4 . Dependent Variabletest....
5 .   19929.38<.0001
6idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  ....
7fact2NOEC NOEO  ....
8REPT31 2 3  ....
9 . Dependent VariableMX....
10 .   1998.50.0044
11idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20  ....
12fact2NOEC NOEO  ....
13REPT31 2 3  ....
14 . Dependent VariableMY....
15 .   1992.260.1356

 

 

I am hoping that the output looks somethig like the following:

 

ObsClassLevelsValuesDependent VariableNumDFDenDFFValueProbF
1idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20test19929.38<.0001
2fact2NOEC NOEO ....
3REPT31 2 3 ....
4idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20MX1998.50.0044
5fact2NOEC NOEO     
6REPT31 2 3 ....
7idsub201 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20MY1992.260.1356
8fact2NOEC NOEO ....
9REPT31 2 3 ....

 

any suggestion on this is highly appreciated.

thanks

HB

 

7 REPLIES 7
PaigeMiller
Diamond | Level 26

Couldn't you do this as a re-arranging of the final output data set from the macro, rather than a modification inside the macro?

--
Paige Miller
HBa
Fluorite | Level 6 HBa
Fluorite | Level 6

thank you for your comment. yes, that would be possible, but since the macro is going to run many times, it will be a large addition to my code if every time that i run the macro, i include lines in the code to change the format of the macro output.

thanks

HB

PaigeMiller
Diamond | Level 26

@HBa wrote:

thank you for your comment. yes, that would be possible, but since the macro is going to run many times, it will be a large addition to my code if every time that i run the macro, i include lines in the code to change the format of the macro output.

thanks

HB


I disagree with this. You need a small addition to the code, that can be placed immediately after the macro, or inside the macro as the last code the macro executes. What difference does it make anyway how large the additional code is anyway, its still one program that you have to run.

--
Paige Miller
Cynthia_sas
SAS Super FREQ
Hi:
While it was good of you to include your code, it's hard to visualize what your input data looks like. Can you provide some fake data to start with or mock up something similar with SASHELP datasets?

It looks like you know how to use ODS OUTPUT and it seems that you probably are using PROC PRINT after the macro runs or else you want to run PROC PRINT after the macro runs. Is there a way to show. Offhand, it looks like your Dependent Variable information is stuck in data rows and not as a header the way you want. You can probably fix this in one of your DATA step programs. I don't use PROC MIXED or have any examples of multiple datasets needing to be analyzed such as you show, so I don't have any other suggestions.

Cynthia
HBa
Fluorite | Level 6 HBa
Fluorite | Level 6

attached are a portion of my data set and the macro. the following is what i run to print the table.

 

data VR3;
set save.tempc;
run;

title 'comparison of NOEC and NOEO';
data temp; set temprept;
if fact ne 'NOEC' and fact ne 'NOEO' then delete;
run;
%HBLST(temp)
proc print data=last2;run;

 

thank you

ballardw
Super User

Maybe instead of this:

data last;                                                                                                                              
set last tempc&i tempa&i tempb&i;                                                                                                       
 if levels=. and numdf = . and Descr ne 'Dependent Variable' then delete;                                                                                                 
drop Effect;
run; 

You are looking for something more like

data last;
  merge work.tempc&i
        work.tempa&i(where=(descr='Dependent Variable'))
        work.tempb&i (drop=effect)
  ;
  rename value=depvar;
  label value='Dependent variable';
  drop descr;
run;

Merge without a BY variable just matches obs1 to obs1 each set, obs2 to obs2 etc.

 

HBa
Fluorite | Level 6 HBa
Fluorite | Level 6

thank you for your response. It seems that it works to some level but not completely. when running the proc mixed, it keeps giving a the following error:

ERROR: The variable Value in the DROP, KEEP, or RENAME list has never been referenced.

In my code, the data LAST was created in every iteration of the loop. by writing

" set last tempc&i tempa&i tempb&i; "

i am basically merging the last data set that was created from previous iteration with he new data. when i applied your suggested code, not only i got the above error, the LAST output of the macro had data only for one round of proc mixed.

thanks again,

HB

sas-innovate-white.png

Our biggest data and AI event of the year.

Don’t miss the livestream kicking off May 7. It’s free. It’s easy. And it’s the best seat in the house.

Join us virtually with our complimentary SAS Innovate Digital Pass. Watch live or on-demand in multiple languages, with translations available to help you get the most out of every session.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 7 replies
  • 3156 views
  • 0 likes
  • 4 in conversation