03-18-2016 08:21 PM
I have a wide dataset similar to following table and want to reshape it to long. Variables' formats: name (character), date(date), new_id and original_id(numeric)
The columns continue to 5.
I used the following code, however it doesn't work and I think the reason is the different formats I have.
ARRAY adate(1:5) date1 - date5 ;
ARRAY anew_id(1:5) new_id1 - new_id5;
ARRAY aoriginal_id(1:5) original_id1 - original_id5;
DO change = 1 to 5 ;
date = adate(change);
DROP date1 - date5 new_id1 - new_id5 original_id1 - original_id5;
I appreciate any and all suggestions.
03-18-2016 09:20 PM
Your code appears correct to the naked eye, and your methodology is correct.
As long as type are the same for the same variable groups that shouldn't be an issue either.
Please post your log and explain how it's not working.
03-18-2016 09:45 PM
The log window looks fine.
NOTE: There were 263872 observations read from the data setWORK.WIDE.
NOTE: The data set WORK.LONG has 1319360 observations and 5 variables.
NOTE: DATA statement used (Total process time): real time 0.11 seconds cpu time 0.10 seconds
However in the newe table values are not correct. For example, the new date variable does not contain date values anymore. It's not even date format, YYMMDD10.
In the following link, example 5, explains the reshaping with a string variable.
Because of this I assumed that format of the date vriable is problematic. However, I don't know why it should be the case when the type of variable (date) is numeric. (its format is YYMMDD10.)
Need further help from the community? Please ask a new question.