BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
ariel_fj
Fluorite | Level 6

"data voter;

input Age Party : $1. (Ques1-Ques4) ($1. +1);

datalines;

23 D 1 1 2 2

45 R 5 5 4 1

67 D 2 4 3 3

39 R 4 4 4 4

19 D 2 1 2 1

75 D 3 3 2 3

57 R 4 3 4 4

;"

Above is a part of code I quoted. What I cannot understand is the "+1" following "$1." in second line.

What is its function? If without it, what will be wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Ksharp
Super User

Party : $1.

Means to eat a character, colon means to stop read when encounter a delimiter blank ,

Because it is list input method, so point will move a unit forward.

(Ques1-Ques4) ($1. +1);

is equal to     Ques1 $1. +1  Ques2 $1. +1   Ques3 $1. +1    Ques4 $1. +1

Ksharp

View solution in original post

4 REPLIES 4
art297
Opal | Level 21

The way it is written, yes, it is needed.  Conversely, something like the following would also work:

data voter;

  informat party ques1-ques4 $1.;

  input Age Party Ques1-Ques4;

  datalines;

23 D 1 1 2 2

45 R 5 5 4 1

67 D 2 4 3 3

39 R 4 4 4 4

19 D 2 1 2 1

75 D 3 3 2 3

57 R 4 3 4 4

;

You have a number of options and capabilities when it comes to inputting data in SAS.  For a nice overview, take a look at:

http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a003209907.htm

Ksharp
Super User

Party : $1.

Means to eat a character, colon means to stop read when encounter a delimiter blank ,

Because it is list input method, so point will move a unit forward.

(Ques1-Ques4) ($1. +1);

is equal to     Ques1 $1. +1  Ques2 $1. +1   Ques3 $1. +1    Ques4 $1. +1

Ksharp

Narendra
Calcite | Level 5

I have one ques..

If I am not giving +1, then it is not taking any values for Ques2 and Ques4, By Default how it is working..plz explain?

Doc_Duke
Rhodochrosite | Level 12

Narenda,

Without the +1, the blanks between the numbers are read as data.  If you look carefully, you would see that the value for Ques3 is actually the value that was meant for Ques2 in the original.

sas-innovate-2024.png

Join us for SAS Innovate April 16-19 at the Aria in Las Vegas. Bring the team and save big with our group pricing for a limited time only.

Pre-conference courses and tutorials are filling up fast and are always a sellout. Register today to reserve your seat.

 

Register now!

What is Bayesian Analysis?

Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 4 replies
  • 2436 views
  • 3 likes
  • 5 in conversation