"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?
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
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
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
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?
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.
Don't miss out on SAS Innovate - Register now for the FREE Livestream!
Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.
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.