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

proc sql;

           select distinct "'"||compress(networkid)||"'"

                  into :nwid SEPaRATED BY ","

                from a1.nw_master

             where srv>0;

               create table  a2.network_links as

                 select * from a1.nw_linkages

                  where id in (&&nwid.);

ERROR: The length of the value of the macro variable NWID (987973) exceeds the maximum length (65534). The value has been truncated

       to 65534 characters.

I thought all distinct values will be selected into nwid macro.

1 ACCEPTED SOLUTION

Accepted Solutions
data_null__
Jade | Level 19

This example is contrived but shows what you "could" do.

proc sql;
  
select * from sashelp.class
     
where name in(select name from sashelp.class where sex eq 'M');
   quit;
  
run;

View solution in original post

6 REPLIES 6
DBailey
Lapis Lazuli | Level 10

I'm not sure you need the double ampersand.

data_null__
Jade | Level 19

This example is contrived but shows what you "could" do.

proc sql;
  
select * from sashelp.class
     
where name in(select name from sashelp.class where sex eq 'M');
   quit;
  
run;
Reeza
Super User

All distinct values will be selected but your string must be longer than the 65k character length.

You can check if that is the case by calculating the number of distinct network ID and then multiplying by 3+ length of network id: total length ~ # of distinct * (length of networkID + 3).

If thats close to 65K then you have a problem.

SASPhile
Quartz | Level 8

Ok..If it greater than 65K sas cannot handle isnt it

data_null__
Jade | Level 19

You don't need the macro variable.

Reeza
Super User

You can use a subquery as shown by Data _null_ or create a macro like identified in this link:

39605 - Create a string that goes beyond the 64K limit for macro variables

I'd go with a subquery, since both tables seem to be in the same location and it would be the fastest.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

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
  • 6 replies
  • 11522 views
  • 7 likes
  • 4 in conversation