I am trying to figure out wha this part of this question is asking "Then use statements a data set with variables year and yield. Specify the year; set yield equal to the variable then use an output statement to put the variable on a single line. Also get rid of most of the missing values by using an if statement with the output (for ex: if y1980 ne . then output;)c. use the following code to summarize the data"
so far I have
data barley; infile "/folders/myfolders/DATASETS/barley.txt" dlm='09'x firstobs=15 expandtabs; input obs y1980 y1982 y1986;
Instead of asking me - what does your output look like? Does it match what you want?
The problem you linked to says "specify year, set yield equal to the variable then use an output statement". While it's true you have three output statements, you don't specify the year value.
It's worded awkwardly, but it is essentially saying to take each observation with three values (yields for 1980, 1982, and 1986) and convert to three observations with two variables: year and yield. YEAR would only have the values 1980, 1982, and 1986. The resulting dataset would have 3 times the number of observations as the starting dataset (excluding missing values, if you so choose). You then could use the YEAR variable as a classification variable, or as an easy way to look at subsets.
I still am confused about what this means.
It means to take this data set (have1), which you already know how to make. (I use a sample of only the first 3 observations from your data):
data have1;
input OBS y1980 y1982 y986;
datalines;
1 211 192 149
2 221 179 132
3 225 134 206
run;
proc print;
run;
And make it to look like this:
data have2;
input OBS @;
do year=1980,1982,1986 ;
input yield @;
output;
end;
datalines;
1 211 192 149
2 221 179 132
3 225 134 206
run;
proc print;
run;
Take a look at the results of the proc prints. The second one has nine lines, one for each obs/year combination.
But instead of making have2 from the original raw data, as I have done above, they want you to make have2 from have1, in a data step program.
Instead of asking me - what does your output look like? Does it match what you want?
The problem you linked to says "specify year, set yield equal to the variable then use an output statement". While it's true you have three output statements, you don't specify the year value.
It's finally time to hack! Remember to visit the SAS Hacker's Hub regularly for news and updates.
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.
Ready to level-up your skills? Choose your own adventure.