Creating Character Variables II
Creating character variables in SAS generally requires a little more attention.
When using the Input statement, SAS assumes all of the variables to be numeric (unless specified otherwise).
Data Test; Input Name Gender Age; Datalines; John Male 31 Mary Female 22 Mark Male 45 ; Run;
The NAME and GENDER variable contain character values. However, they are not captured in the data set created.
To create the character variables properly, you must add the dollar sign ($) in the Input statement after each character variables:
Data Test; Input Name $ Gender $ Age; Datalines; John Male 31 Mary Female 22 Mark Male 45 ; Run;
The dollar sign ($) tells SAS to create NAME and GENDER as character variables.
Create a data set that contains the following variables:
Name the data set as PROFILE.
Need some help?
Simply add the dollar sign ($) AFTER each character variables and you should be able to create the correct data set.
Input PAT_ID $ Enrol $ BScore;
P001 Yes 99
P002 Yes 101
P003 No 125