BookmarkSubscribeRSS Feed
rykwong
Quartz | Level 8

Friends at SAS communities

I have really struggled with this macro given to me by a colleague who is no longer available.  It had work but suddenly failed (please see log file and the sas code).  I have little knowledge of fixing this macro but really it to run to assess for effect modifications of a large number of variables.

 

Many thanks in advance

Raymond

 

3 REPLIES 3
art297
Opal | Level 21

You didn't show the code you used to call the macro. Seeing that would definitely help as would your posting the actual macro.

 

Art, CEO, AnalystFinder.com

 

 

rykwong
Quartz | Level 8

sorry, this is the code I used.  The proc mixed is in this code.  I resticted the variables to just age and female but I need to run the code across a large number of variables.  Many thanks 

 

 

%macro loop(var);                                                                                                                       

data pv1_&var;                                                                                                                          

format y $20.

y=''

run;                                                                                                                                    

%let endpoint=ln_lvesv_rep ecv_rem_rep;

                                              

%do i=1 %to 2;                                                                                                                          

%let y=%scan(&endpoint,&i,' ');                                                                                                         

title "Endpoint = &y";                                                                                                                  

ODS OUTPUT SOLUTIONF=RESULTS;                                                                                                           

proc mixed data=longformat_stemi covtest noclprint plots=studentpanel method=reml;                                                               

class patient_id site_id;                                                                                                               

model0: model &y = drug &var drug*&var/ s cl ddfm=kenwardroger;     

repeated / type=un subject=patient_id r; 

run;                                                                                                                                    

DATA pv1_&var;                                                                                                                          

SET pv1_&var RESULTS(IN=A);                                                                                                             

if missing(effect) then delete;                                                                                                         

IF A THEN Y="&y";                                                                                                                       

RUN;                                                                                                                                    

                                                                                                                                        

%end;                                                                                                                                   

title " ";                                                                                                                              

%mend;                                                                                                                                  

                                                                                                                                        

%macro lst(dsn);                                                                                                                        

  /** open dataset **/                                                                                                                  

  %let dsid=%sysfunc(open(&dsn));                                                                                                       

                                                                                                                                        

  /** cnt will contain the number of variables in the dataset passed in **/                                                             

  %let cnt=%sysfunc(attrn(&dsid,nvars));                                                                                                

                                                                                                                                        

   %do j = 1 %to &cnt;                                                                                                                  

    %loop(%sysfunc(varname(&dsid,&j)))                                                                                                  

   %end;                                                                                                                                

                                                                                                                                        

%mend lst;                                                                                                                              

 

/** Sample data set **/                                                                                                                                       

data test2; set longformat_stemi;

keep  

age female

;

run;

                                                                                                                                                                                                                                                                                                                                                                                                  

%lst(test2) 

 

ballardw
Super User

Microsoft Docx files are not ideal for posting code or log information. Many users here don't want to download the because of virus potential, others have such things blocked by security software. Also when attempting to run code copied from docx files sometimes Word has introduced "features" such as smart quotes, the curly versions instead of " as entered from the keyboard or sometimes not visible formatting code that causes code not to run when pasted into the SAS editor and executed. Best is to copy and paste into a codebox opened using the menu {i} icon in the forum message box.

 

 

General comment: When data has been running and then quits it almost always points to something different in the data processed. A very common source of differences that will cause that are data sets created using Proc Import or read from Excel. One version of the file may now be treating a field as character that was previously numeric or vice versa.

 

You have a lot of warnings that WORK.Result does not exist. That tells me that possibly a previous step did not run properly or you are running this code out of sequence. Also your models seem to keep looking at data with only one or no valid records in this case.

 

Learn to use OPTIONS MPRINT SYMBOLGEN; with macros for debugging. That will place the error or warning messages in better relationship to the code that is causing issues.

sas-innovate-2024.png

Today is the last day to save with the early bird rate! Register today for just $695 - $100 off the standard rate.

 

Plus, pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

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.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 3 replies
  • 658 views
  • 0 likes
  • 3 in conversation