BookmarkSubscribeRSS Feed
sreeparna93
Calcite | Level 5

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 
2 REPLIES 2
RW9
Diamond | Level 26 RW9
Diamond | Level 26

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.

Kurt_Bremser
Super User

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?

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

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
  • 2 replies
  • 3030 views
  • 0 likes
  • 3 in conversation