Learning SAS? Welcome to the exclusive online community for all SAS learners.

How do I display all of my variables using datalines

Accepted Solution Solved
Reply
Occasional Contributor
Posts: 7
Accepted Solution

How do I display all of my variables using datalines

Hi, 

I attempted what I thought was super simple. When I ran the datalines program (typed below) I received no errors and no warnings. When I looked at my results.

 

The ten character variable (names) appear listed in the first column. However, for the second variable (numeric  ) the report indicates that the corresponding data for each observation is missing (.) .

 

I've tried every variation I've seen or can think of. Below are my "Results", my coding, and the "non-error" note I received.  I am using SAS Studio (I think 9.2)  Thanks in advance.

 

RESULTS 

Name Generation 

William.
Mildred.
Tina.
Bill.
Roberta.
Will.
Tiffany.
Shawn.
Twila.
James

 

CODING

data family;
     input Name $ Generation;
datalines;
William Williams 1
Mildred Williams 1
Tina Williams 2
Bill Williams 2
Roberta Williams 2
Will Williams 3
Tiffany Williams Gates 3
Shawn Williams 3
Twila Williams 3
James Williams 3
;
run;

 

MESSAGE

Though there is no error nessage, I have 12 notes ( two standard - processing time and obs & var count + 10 "invalid data messages). A sample follows:

 

NOTE: Invalid data for Generation in line 59 9-16.
RULE: ----+----1----+----2----+----3----+----4----+----5----+----6----+----7----+----8----+----9----+----0
59 William Williams 1

or message, 

 

 

 

 

 


Accepted Solutions
Solution
‎03-10-2016 04:07 PM
Respected Advisor
Posts: 3,777

Re: How do I display all of my variables using datalines

Try this version.

 

data family;
   input Name &$24. Generation;
   datalines;
William Williams  1
Mildred Williams  1
Tina Williams  2
Bill Williams  2
Roberta Williams  2
Will Williams  3
Tiffany Williams Gates  3
Shawn Williams  3
Twila Williams  3
James Williams  3
;;;;
   run;

View solution in original post


All Replies
Solution
‎03-10-2016 04:07 PM
Respected Advisor
Posts: 3,777

Re: How do I display all of my variables using datalines

Try this version.

 

data family;
   input Name &$24. Generation;
   datalines;
William Williams  1
Mildred Williams  1
Tina Williams  2
Bill Williams  2
Roberta Williams  2
Will Williams  3
Tiffany Williams Gates  3
Shawn Williams  3
Twila Williams  3
James Williams  3
;;;;
   run;
Occasional Contributor
Posts: 7

Re: How do I display all of my variables using datalines

Smiley Very HappyDare I ask why it worked! If I had a frozen Reese's Cup, it would be yours!! Thanks so much.

Respected Advisor
Posts: 3,777

Re: How do I display all of my variables using datalines

The & tells SAS to read until 2 spaces are found (changes delimiter from 1 to 2 spaces for this field) so you can use list input to read a field with blanks in it like name.   $24. defines the length of character variable.

☑ This topic is solved.

Need further help from the community? Please ask a new question.

Discussion stats
  • 3 replies
  • 591 views
  • 6 likes
  • 2 in conversation