This is a beginner's questions. I'm wondering what the syntax error in the following is:
data work.ds2;
array Response{*} a b c d e;
run;
data ds2;
set ds2;
input;
datalines;
1 2 3 4 5
;
run;
I don't know why the 1 2 3 4 5 isn't entering in the the original table. I tried it with/without input; with no luck. Thanks for any help.
The specific problem is that you are using a null input statement. That form of an input statement does not create any variables. If you want to read in the variables, you have to specify the list of variables, using the statement, say, INPUT A B C D E;
A different problem is that you don't need two data steps; in fact the first one is basically irrelevant. The first data step does set up five variables, a through e, with missing values and creates a dataset. The second data step replaces the first dataset. Try the following:
data work.ds2 (drop=i);
array response {*} a b c d e;
do i = 1 to dim(response);
response{i} = i;
end;
run;
Now open up the dataset and look at the values. Then close it and run the next step:
data ds2;
set ds2;
input a b c d e;
datalines;
6 7 8 9 10
;
run;
Note that there is only one record. Open up the data set. You will now have different values in those variables.
I hope this helps.
Not sure what you are trying to do. The first datastep, where you declare an array, probably isn't necessary.
If you do need it, and are only trying to add one record with those five values, you probably only need to change the third line of the second program. i.e., instead of input; use input a b c d e;
HTH,
Art
The specific problem is that you are using a null input statement. That form of an input statement does not create any variables. If you want to read in the variables, you have to specify the list of variables, using the statement, say, INPUT A B C D E;
A different problem is that you don't need two data steps; in fact the first one is basically irrelevant. The first data step does set up five variables, a through e, with missing values and creates a dataset. The second data step replaces the first dataset. Try the following:
data work.ds2 (drop=i);
array response {*} a b c d e;
do i = 1 to dim(response);
response{i} = i;
end;
run;
Now open up the dataset and look at the values. Then close it and run the next step:
data ds2;
set ds2;
input a b c d e;
datalines;
6 7 8 9 10
;
run;
Note that there is only one record. Open up the data set. You will now have different values in those variables.
I hope this helps.
Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 16. Read more here about why you should contribute and what is in it for you!
Learn how use the CAT functions in SAS to join values from multiple variables into a single value.
Find more tutorials on the SAS Users YouTube channel.
Select SAS Training centers are offering in-person courses. View upcoming courses for: