11-29-2016 11:01 PM
I have a data set that have 48 temperatures that correspond to two 24 hour days. I want to create a variable that is 1 if it occurs in the first day and 2 if it occurs in the second. I used a do loop to create the Hour variable.
do Hours=1 to 24;
11-29-2016 11:07 PM
Are you reading SAS data from sas dataset HOT? If so you don't need the INPUT statement which is intended to read raw data.
So lets assume you have 48 obs, i.e. 24 for day 1 and 24 for day 2.
Then you could do this:
if _n_<=24 then day=1;
The automatic variable _N_ above is the iteration number of the data set, which corresponds in this case to the observation number.
11-29-2016 11:14 PM
I was reading in a raw text file, but to save space and some personal details I subsituted the path for 'HOT.' I initially tried to use the _N_ for this, but I can't seem to get it to work correctly with the do loop. Any ideas?
Need further help from the community? Please ask a new question.