BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
bergsorensen
Calcite | Level 5

Im having a small issue creating an XML output.

Each variable in my put statement, generates and blank after it (which it shouldnt!).

Heres a small sample code:

data _null_;

set step2 end=eof;

output;

file  'c:\Data.xml';

if _n_=1 then do;

  put '<chart>';

end;

  put '<set label="'visityearweek'" value="'count'"/>';  <----- PROBLEM!

if (eof=1) then do;

  put '</chart>';

end;

run;

Current output:

<set label="2014-04 " value="2839 "/> <--- BLANKS after var..!

<set label="2014-05 " value="3232 "/>

<set label="2014-06 " value="2433 "/>

Anyone got an idea why this occurs? (i have tried to compress/strip the variables first without luck, theres no blanks in data).

Best

Kasper

1 ACCEPTED SOLUTION

Accepted Solutions
RichardinOz
Quartz | Level 8

Try

put '<set label="'visityearweek+(-1)'" value="'count+(-1)'"/>';


Richard

View solution in original post

4 REPLIES 4
bergsorensen
Calcite | Level 5

Issue not resolved.

RichardinOz
Quartz | Level 8

Try

put '<set label="'visityearweek+(-1)'" value="'count+(-1)'"/>';


Richard

bergsorensen
Calcite | Level 5

Thanks - thats the (though its not logic why needed) solution.

RichardinOz
Quartz | Level 8

The put statement by default adds a delimiting space at the end of each variable printed so list output does not run everything together. 

In this context the + is a pointer control, so +9 would move the pointer (the next printing position) 9 spaces further. 

There is no '-' pointer control so if you need to move back one space you need to advance the pointer control by (-1).

An alternative would be to place your text and values explicitly using the @ pointer, but you might have to calculate the length of the count variable each time.

Richard

sas-innovate-2024.png

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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