BookmarkSubscribeRSS Feed
Attyslogin
Obsidian | Level 7

 

Proc sql;

select data into  :data_macro seperated by "," from xyz;

quit;

 

Lets assume data_macro recorded a string of 65k length.

 

Now :

 

data test;

data_list="&data_macro"; /*Here error comes of truncation*/ 

run;

 

Since character varibale can store max 32767 byte of data i am wondering how will i able to store this macro value into my dataset.

 

Kindly suggest.

 

Thanks

6 REPLIES 6
Kurt_Bremser
Super User

Since the data is originally stored in a column over all (or multiple) rows, I'd keep it that way and use it from there. Adapt your process to the structure.

 

With an arbitrary number of rows, sooner or later you'll crack the 65k limit of the macro variable and lose data there. So your process as such is not valid.

PaigeMiller
Diamond | Level 26

data test;

data_list="&data_macro"; /*Here error comes of truncation*/ 

run;

 

I can't imagine a reason to do this, why you'd want to create a data step variable that long from a macro variable, what is the point?

 

But when you start dealing with large amounts of text like this, the idea of making a huge long text string or huge long macro variable is not a good one. Using a function like CALL EXECUTE, you can actually work with arbitrarily large amounts of text, if you do it properly.

 

 

--
Paige Miller
Tom
Super User Tom
Super User

There is a simple answer DON'T.

 

If you describe the larger problem I am sure there is a way to solve it without creating strings anywhere near the 32K limit for a variable to or the 64K limit for a macro variable.

 

If you really want to generate really long strings from your data then just do that and skip the macro variable step.

data test ;
  length row 8 data_list $500 ;
  do row=1 by 1 until (eof or length(data_list) > 450) ;
    set xyz end=eof ;
    data_list = catx(',',data_list,data);
  end;
  keep row data_list ;
run;
SuryaKiran
Meteorite | Level 14

Instead of saving it into a single macro, you can use CALL SYMPUT in data step and create multiple macro variables depending on the condition you have and later you can call them as needed. 

 

Thanks,
Suryakiran
ballardw
Super User

@Attyslogin wrote:

 

Proc sql;

select data into  :data_macro seperated by "," from xyz;

quit;

 

Lets assume data_macro recorded a string of 65k length.

 

Now :

 

data test;

data_list="&data_macro"; /*Here error comes of truncation*/ 

run;

 

Since character varibale can store max 32767 byte of data i am wondering how will i able to store this macro value into my dataset.

 

Kindly suggest.

 

Thanks


And just what were you going to do with the data step variable data_list?

Sticking that many data values into macro variables is almost always an indication of attempting to do something in the macro facility it was not designed for. Not to mention what is going to be done with one variable roughly the equivalent of 300 pages of text...

Reeza
Super User

See the recommendation here:

http://support.sas.com/kb/39/605.html

 

Check the full code tab for the code.

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
  • 1903 views
  • 0 likes
  • 7 in conversation