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
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.
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.
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;
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.
@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...
See the recommendation here:
http://support.sas.com/kb/39/605.html
Check the full code tab for the code.
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
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.
Ready to level-up your skills? Choose your own adventure.