Hey there! Looks like you have not set up the training properly 🙂
This training web page is designed to be open side-by-side with your SAS program.
Please see the instruction on how to set up the training.
Data Truncation
Data Truncation often happens when you create a character variable that is longer than eight characters.
Example
Data Test;
Input Name $ Gender $;
Datalines;
Christopher Male
Elizabeth Female
MacDonald Male
;
Run;
Each of the names above is longer than eight characters.
The default length of a character variable is eight. Any variable that contains more than eight 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;
A dollar sign ($) is added before the number 12. This is needed when adjusting the length of a character variable.
? Sign up for a free SASCrunch account now and keep track of your learning progress!
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. |