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?
Available on demand!
Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.
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.