Data Truncation
Data Truncation often happens when you create a character variable that is longer than 8 characters.
Example
Data Test;
Input Name $ Gender $;
Datalines;
Christopher Male
Elizabeth Female
MacDonald Male
;
Run;
Each of the names above is longer than 8 characters.
The default length of a character variable is 8. Any variable that contains more than 8 characters will get cut off.
(Try it!)
The data truncation problem can be easily solved by adding a Length statement.
Example
Data Test;
Length Name $12;
Input Name $ Gender $;
Datalines;
Christopher Male
Elizabeth Female
MacDonald Male
;
Run;
The Length statement changes the length of the NAME variable from 8 to 12.
As a result, the complete name is now captured in the data set.
Note:
Length Name $12
1. A dollar sign ($) is added before the number 12. This is needed when adjusting the length of a character variable.
Exercise
Create a data set that contains the following variables:
Name the data set as PROFILE.
Need some help?
HINT:
The Length statement is needed for the variable PAT_ID.
SOLUTION:
Data Profile;
Length PAT_ID $ 10;
Input PAT_ID $ Enrol $ BScore;
Datalines;
PAT3000001 Yes 99
PAT3000002 Yes 101
PAT3000003 No 125
;
Run;
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |