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

Hello,

I'm having trouble with making a new variable that will count the 'correct' answers in the first 17 questions on a survey. Whenever I use this code:

Data HW4set;
If 1 = p1p then Correct=correct+1;
If 1 = p2p then Correct=correct+1;
Run;

It just deletes all the data from the set. It turns the set from this:

Diana___0-1601253013600.png

to this:

Diana___1-1601253071683.png

 

Which I don't understand, it hasn't worked with various attempts, and it won't even make a variable that is constant such as:

DATA HW4set;
Always6=6;
Run;

It just erases the data set again, even though I got it straight from an example. There are no errors displayed either, it only says that p1p and p2p are uninitialized.

1 ACCEPTED SOLUTION

Accepted Solutions
SASKiwi
PROC Star

Your program doesn't read any data, just writes data out. I suspect you need to do something like this:

 

DATA HW4set;
set Mylib.Hw4;
Always6=6;
Run;

View solution in original post

2 REPLIES 2
SASKiwi
PROC Star

Your program doesn't read any data, just writes data out. I suspect you need to do something like this:

 

DATA HW4set;
set Mylib.Hw4;
Always6=6;
Run;
PaigeMiller
Diamond | Level 26
Data HW4set;
Set HW4set;
If 1 = p1p then Correct=correct+1;
If 1 = p2p then Correct=correct+1;
Run;

Without the set statement, the data step doesn't know and doesn't care that there was a previous data set named HW4set.

--
Paige Miller