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

Hi,

 

I am converting two numeric variables to character and then  I am concatenating them. After concatenating the the result variable shows  zero instead the vale expected. Could you please help me on this.

 

data med_23;
length llimit ulimit plci $100;
set plot21;
if ^missing(lowerlimit) then llimit=compress(strip(put(lowerlimit,6.2)));
else llimit="NE";
if ^missing(upperlimit) then ulimit=compress(strip(put(upperlimit,6.2)));
 else ulimit="NE";


 if ^missing(llimit) and ^missing(ulimit) then plci = strip(put(estimate,6.3))||" ("||llimit||", "|ulimit||")";

run;

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenKuhfeld
Ammonite | Level 13

 if ^missing(llimit) and ^missing(ulimit) then plci = strip(put(estimate,6.3))||" ("||llimit||", "|ulimit||")";

 

should be

 

 if ^missing(llimit) and ^missing(ulimit) then plci = strip(put(estimate,6.3))||" ("||llimit||", "     ||   ulimit||")";

 

I added a vertical bar. The added white space was just to make it easier for you to see. You should really look into the cat series of functions, ifc, ifn, etc. They make life easier. You should use one of the cat* functions instead of what you are doing, because you are not stripping values of your intermediate variables before concatenating.

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

We need to see (a portion) of your data as SAS data step code, pasted into your message after clicking on the "running man" icon. (If your data is in the attachment, many of us will not or can not download attachments as they are a security risk).

 

It seems to me that LLIMIT and ULIMIT ought to be numeric variables rather than character variables, which would make your programming simpler and perhaps would eliminate the problem you are having. 

 

 

--
Paige Miller
WarrenKuhfeld
Ammonite | Level 13

 if ^missing(llimit) and ^missing(ulimit) then plci = strip(put(estimate,6.3))||" ("||llimit||", "|ulimit||")";

 

should be

 

 if ^missing(llimit) and ^missing(ulimit) then plci = strip(put(estimate,6.3))||" ("||llimit||", "     ||   ulimit||")";

 

I added a vertical bar. The added white space was just to make it easier for you to see. You should really look into the cat series of functions, ifc, ifn, etc. They make life easier. You should use one of the cat* functions instead of what you are doing, because you are not stripping values of your intermediate variables before concatenating.

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
  • 954 views
  • 0 likes
  • 3 in conversation