Hi,
I have compared my solution to the solution shown for lesson 3, practice 5, but I only get a single row of output.
data is:
Output line from my attempt:
I have used ChatGPT to assess whether the solution and my solution is doing the same thing, and it seems to be doing the exact same thing, so I don't know where i'm going wrong.
I have also tried to use their keywords in the do-loops, but that has not solved
My Solution:
data work.MaxWind; array MWTable[1980:2016,4] _temporary_; if _N_=1 then do S=1980 to 2016; set pg3.storm_maxwindseasqtr; array MWQ[4] MaxWindQ1-MaxWindQ4; do Q=1 to 4; MWTable[S,Q]=MWQ[Q]; end; end; set pg3.storm_stats; Qtr=qtr(StartDate); MaxWindSQ=MWTable[Season,Qtr]; Difference=MaxWindMPH-MaxWindSQ; drop S Q MaxWindQ1-MaxWindQ4; run;
The guided solution is the following:
data work.MaxWind; array MWTable[1980:2016,4] _temporary_; if _N_=1 then do S=1980 to 2016; set pg3.storm_maxwindseasqtr; array MWQ[4] MaxWindQ1-MaxWindQ4; do Q=1 to 4; MWTable[S,Q]=MWQ[Q]; end; end; set pg3.storm_stats; Qtr=qtr(StartDate); MaxWindSQ=MWTable[Season,Qtr]; Difference=MaxWindMPH-MaxWindSQ; drop S Q MaxWindQ1-MaxWindQ4; run;
What am I doing wrong?
Best,
Alex
I think you need to add _N_ = 1, otherwise the IF statement will be true for every iteration of the data step.
I think you need to add _N_ = 1, otherwise the IF statement will be true for every iteration of the data step.
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 25. Read more here about why you should contribute and what is in it for you!
Follow along as SAS’ Robert Blanchard explains three aspects of autotuning in a deep learning context: globalized search, localized search and an in parallel method using SAS.
Find more tutorials on the SAS Users YouTube channel.