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
Rhodochrosite | Level 12

 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
Rhodochrosite | Level 12

 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.

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
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
  • 489 views
  • 0 likes
  • 3 in conversation