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

Hello!

 

I'm working on creating a label for variables that are being created, but I'd like them to have the old names as their labels.  I keep gettin an error message saying there is a syntax error on the LABEL line.

 

Any help is greatly appreciated!!

 

DATA %SCAN(&DATA,&i);
SET %SCAN(&DATA,&i);
ARRAY %SCAN(&DATA,&i) [&Count] &List;
ARRAY BIN_%SCAN(&DATA,&i)[&Count] BIN_%SCAN(&DATA,&i)1 - BIN_%SCAN(&DATA,&i)&Count;
DO j = 1 TO &Count;
IF %SCAN(&DATA,&i)(j) = '' THEN BIN_%SCAN(&DATA,&i)(j) = 0;
ELSE BIN_%SCAN(&DATA,&i)(j) = 1;
LABEL BIN_%SCAN(&DATA,&i)(j) = %SCAN(&DATA,&i)(j);
END;
FORMAT BIN_%SCAN(&DATA,&i)1 - BIN_%SCAN(&DATA,&i)&Count Issues.;
RUN;

1 ACCEPTED SOLUTION

Accepted Solutions
Katie
Obsidian | Level 7

Thank you!  I looked at it differently and did make it much easier.  

 

Thank you :).

View solution in original post

2 REPLIES 2
Reeza
Super User

I don't think you can reference a variable to assign a label by using the array reference, ie this line:

 

LABEL BIN_%SCAN(&DATA,&i)(j) = %SCAN(&DATA,&i)(j);

You'll need to either get the variables names which you may have in another macro variable (LIST)

or you can do it in another step, using the metadata from SASHELP.VCOLUMN and PROC DATASETS.

 

I'm looking at your code though and betting there's an easier way to accomplish what you're trying to do....so what are you trying to do 🙂

Katie
Obsidian | Level 7

Thank you!  I looked at it differently and did make it much easier.  

 

Thank you :).

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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
  • 2 replies
  • 808 views
  • 1 like
  • 2 in conversation