Hi I want to add line while concatenating variables. tried a few things. Dont seem to get it done.
The code is
DATA Y;
SET result;
INFORMAT R $100.;
format R $100.;
R = CATX(":" ,"CDE" , cde_name, "Attribute", attrib_name);
where total_record_count gt 10.00 or total_record_count lt -10.00;
RUN;
PROC PRINT;
title 'Y';
RUN;
proc sql;
select (catx("^{newline 1}",R)) into :var separated by '^{newline 1}' from y
where total_record_count gt 10.00 or total_record_count lt -10.00;
run;Now I only get CDE:PRODUCT HIERARCHY:Attribute:PRD_HRCHY_LVL_2_CDE^{newline 1}CDE:PRODUCT
Sorry, your post is not clear. Post test data, in the form of a datastep. Also post what you want out at the end. Why for instance are you taking data from a datastep and putting it and formatting values into a macro variable? Its likely your hitting a length issue, but really can't tell what you trying to do at all. If you want some sort of list then:
data y;
set result (where=(total_record_count gt 10.00 or total_record_count lt -10.00)) end=last;
length r final $2000;
retain final;
r=catx(":","CDE",cde_name,"Attribute",attrib_name);
final=ifc(_n_=1,r,catx(":",final,r));
if last then call symputx('VAR',final);
run;
However that really isn't a good way to do things, you will hit line var lengths and your code will be all spaghetti.
Don't keep lists in macro variables. Keep them in datasets. It is much easier to create line-separated output with proc print or a data step.
What for would you use such a macro variable, anyway?
April 27 – 30 | Gaylord Texan | Grapevine, Texas
Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!
Still thinking about your presentation idea? The submission deadline has been extended to Friday, Nov. 14, at 11:59 p.m. ET.
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.