BookmarkSubscribeRSS Feed
attaman2008
Calcite | Level 5
Hello, anybody knows how to check if macro variable's length exceeds max length (65534) while select into runs?
E.g.
proc sql;
select x into :y separated by " " from z;
quit;
Macro var Y is always created nevertheless its lenght, but when I'm trying to use it further it, of course, invokes an error if length is more than 65534
3 REPLIES 3
sbb
Lapis Lazuli | Level 10 sbb
Lapis Lazuli | Level 10
You may want to explore using the DICTIONARY TABLES and SAS-maintained member/view DICTIONARY.COLUMNS to at least verify the incoming data column/variable length before proceeding with another SELECT.

Search the SAS support http://support.sas.com/ website using this Google advanced argument or with using the SAS support website search:

dictionary columns variable length site:sas.com


Scott Barry
SBBWorks, Inc.
LinusH
Tourmaline | Level 20
Since the into: construct also does an implicit COMPBL type of compress, you have to scan each value on beforehand and calculating the real length of your macro variable. If your sample code was relevant, I think a simple data step will do the job.


/Linus
Data never sleeps
DanielSantos
Barite | Level 11
Try to check the variable lenght with a CASE WHEN END statement.

proc sql;
select case when length(x) > 65534 then '' else x end into :y separated by " " from z;
quit;

Cheers from Portugal.

Daniel Santos @ www.cgd.pt

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
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
  • 3 replies
  • 1280 views
  • 0 likes
  • 4 in conversation