BookmarkSubscribeRSS Feed
Jasdeep_Kochhar
Calcite | Level 5

I have an XML file in the following structure:

 

<root>

<a>

<b>

<c>

<d>

<e>

<f>

<g> value1 </g>

</f>

<f>

<g> value2 </g>

</f>

</e>

</d>

</c>

</b>

</a>

<a>

<b>

<c>

<d>

<e>

<f>

<g> value3 </g>

</f>

<f>

<g> value4 </g>

</f>

</e>

</d>

</c>

</b>

</a>

</root>

 

Since the element "g" is repeating within the following observation boundary/table-path:

 

/root/a,

 

when I set the column-path in my XML map equal to: 

 

/root/a/b/c/d/e/f/g,

 

I expect (based on this webpage) the value of column g for the first observation to equal the concatenation value1value2. However, the first observation has value of column g equal to value1, which also happens if I set the table-path/observation boundary equal to any of: 

 

/root/a, /root/a/b, ..., /root/a/b/.../e.

 

If I set the observation boundary/table-path in my XML map to: 

 

/root/a/b/.../e/f

 

I get value1 and value2 in separate observations/rows, as expected.

 

Does anyone know how I can get the concatenation I want to work?

2 REPLIES 2
ballardw
Super User

Can you indicate which lines in the referenced link lead to this expectation?

I expect (based on this webpage) the value of column g for the first observation to equal the concatenation value1value2. However, the first observation has value of column g equal to value1, which also happens if I set the table-path/observation boundary equal to any of: 

 

If the "values" are numeric then that would be a serious abuse of the data. You can't "concatenate" numerics if the field is supposed to be numeric.

 

You will have to go with the second approach and then write code to concatenate the values after it is in a data set. There are numerous requests and responses on how to do that on this forum.

 

 

Jasdeep_Kochhar
Calcite | Level 5

Hi @ballardw,

 

Thanks for your reply. The third paragraph states: 

 

"If you do not identify the appropriate observation boundary, the result could be a concatenated data string instead of separate observations."

 

Although I realise now that this says it the result could be a concatenated data string, but it does not say that this will definitely happen.

 

In regards to using the second approach, I'm okay to do this using retained variables after the data has been set.

 

Thanks for all your help.

 

 

hackathon24-white-horiz.png

2025 SAS Hackathon: There is still time!

Good news: We've extended SAS Hackathon registration until Sept. 12, so you still have time to be part of our biggest event yet – our five-year anniversary!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 2 replies
  • 962 views
  • 0 likes
  • 2 in conversation