BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
Katie
Obsidian | Level 7

I have the following code: 

 

%MACRO DATAPREP(DATA);
%DO i = 1 %TO 1;

PROC SORT DATA = FIMR.Sleep_Logistic;
BY Case_ID__;
RUN;

PROC SORT DATA = FIMR.%SCAN(&DATA,&i);
BY Case_Number;
RUN;

DATA %SCAN(&DATA,&i);
MERGE FIMR.Sleep_Logistic (IN = A KEEP = Case_ID__ RENAME = (Case_ID__ = Case_Number)) FIMR.%SCAN(&DATA,&i) (IN = B);
BY Case_Number;
IF A and B;
RUN;

PROC CONTENTS DATA = %SCAN(&DATA,&i) NOPRINT OUT = Contents_%SCAN(&DATA,&i);
RUN;

DATA Contents_%SCAN(&DATA,&i);
SET Contents_%SCAN(&DATA,&i);
IF Length NE 1 THEN DELETE;
IF Name = 'Fetal__F__Infant__I_' THEN DELETE;
KEEP Name VarNum;
RUN;

PROC SQL;
SELECT DISTINCT Name
INTO :List_%SCAN(&DATA,&i) SEPARATED BY ' '
FROM Contents_%SCAN(&DATA,&i)
ORDER BY VarNum;
QUIT;

%END;

%MEND;

 

%DATAPREP(DATA = Environment);

 

When I then type the following: 

 

%PUT &List_Environment; 

 

I get an error that states that the symbolic reference List_Environment is not resolved.  Please HELP.

1 ACCEPTED SOLUTION

Accepted Solutions
FreelanceReinh
Jade | Level 19

Hi @Katie,

 

Please add the following statement to your macro (e.g. before the PROC SQL step).

%GLOBAL List_%SCAN(&DATA,&i);

Edit: %GLOBAL List_Environment; would work only for this specific macro variable, but in your case the name is dynamic.

View solution in original post

2 REPLIES 2
FreelanceReinh
Jade | Level 19

Hi @Katie,

 

Please add the following statement to your macro (e.g. before the PROC SQL step).

%GLOBAL List_%SCAN(&DATA,&i);

Edit: %GLOBAL List_Environment; would work only for this specific macro variable, but in your case the name is dynamic.

Katie
Obsidian | Level 7

THANK YOU! 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 2 replies
  • 778 views
  • 2 likes
  • 2 in conversation