Search code examples
sas

how can I manually create a test dataset in SAS including strings?


I want to create a small SAS dataset for testing. This works when I have just number data types but not with strings ("media" column):

data want;
  input ID num media;
datalines;
1 200 "film"
2 50 "art"
3 100 "music"
run;

The above shows the "media" column empty. I guess I'm not defining it properly. How do I specify it's a string?


Solution

  • You need a $ after media in the input statement to tell SAS that it's a character variable.

    And you don't need the quotes in the data lines.

    data want;
      input ID num media $;
    datalines;
    1 200 film
    2 50 art
    3 100 music
    run;