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

Thank you for your reply

 

data a;
a9=123456789;
a15=123456789123456;
a20=12345678912345678912;
format a15 15.  a20  20.;
run

Image.jpg 

1 ACCEPTED SOLUTION

Accepted Solutions
ChrisNZ
Tourmaline | Level 20

Many resources are available if you want to understand how computers store numbers.

For example search for SAS numerical precision.

View solution in original post

5 REPLIES 5
Tom
Super User Tom
Super User

The display format used for a number does not change how the numbers are stored.  If your values have more than 15 decimal digits you cannot store them as a number in SAS because SAS stores all numbers as floating point values.  Once the number of significant digits exceeds the amount that can be stored in that way you will lose some of the lower order digits.  

 

If those values are identifiers then store them as character strings.

 

If they are numbers does it REALLY matter whether the value is 12,345,678,912,345,678,912 or 12,345,678,912,345,600,000?  How will that trivial difference impact the analysis your going to do with them?

Cingchih
Quartz | Level 8

In fact, my question is that six big datasets merge  into a dataset. However, they do not share variable (also known as key variable).

 

I converted several variables into string attributes, and then concatenated all of them to form the key variables used in the merge. So, the examples I have presented are actually simplified. I have resolved this through full join of proc sql, and thank you for your response.

The attached picture is my key variable. It is composed of 4 variables.

 

Image 026.png

Tom
Super User Tom
Super User

@Cingchih wrote:

In fact, my question is that six big datasets merge  into a dataset. However, they do not share variable (also known as key variable).

 

I converted several variables into string attributes, and then concatenated all of them to form the key variables used in the merge. So, the examples I have presented are actually simplified. I have resolved this through full join of proc sql, and thank you for your response.

The attached picture is my key variable. It is composed of 4 variables.

...


Your two paragraphs are contradictory.  If the six datasets do not share key variables then how did you generate a key variable?  Why did you concatenate?  Why not just merge by the 4 variables?

data want;
  merge big1-big6;
  by a b c d;
run;

If you do have to build some type of variable to try to match them then make sure to generate it in a consistent way.  If the values of any of the original variables vary in the number of characters used to represent them then you most likely want to either force all of the values to use the same number of characters in the generated string

 A    B  C  D    ABCD
-- ---- -- -- ------------
ab  123 xy 67 ab0123xy67
c  4567  w  8 .c4567.w08

, or use some type of separator.

 A    B  C  D    ABCD
-- ---- -- -- ------------
ab  123 xy 67 ab|123|xy|67
c  4567  w  8 c|4567|w|8

PS Why is it that so many users on this forum jump through hoops to post photographs of their data.  Just copy and paste the text. 

Cingchih
Quartz | Level 8

Thank you for your reply, and I will study it later.

ChrisNZ
Tourmaline | Level 20

Many resources are available if you want to understand how computers store numbers.

For example search for SAS numerical precision.

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