DATA Step, Macro, Functions and more

Select into: checking length of varible

Reply
Occasional Contributor
Posts: 7

Select into: checking length of varible

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
Super Contributor
Super Contributor
Posts: 3,174

Re: Select into: checking length of varible

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.
Super User
Posts: 5,257

Re: Select into: checking length of varible

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
Super Contributor
Posts: 474

Re: Select into: checking length of varible

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
Ask a Question
Discussion stats
  • 3 replies
  • 206 views
  • 0 likes
  • 4 in conversation