To a variable where you can change the Structure to Date/Time to use it as a date variable set.
- A data set loaded into Displayr that contains a categorical variable that requires converting to a Date/Time variable e.g., year, quarter, month, and week.
if (week == 1) Q.EncodeDate(2021,01,04);
else if (week == 2) Q.EncodeDate(2021,01,11);
else if (week == 3) Q.EncodeDate(2021,01,18);
else if (week == 4) Q.EncodeDate(2021,01,25);
else if (week == 5) Q.EncodeDate(2021,02,01);
else if (week == 6) Q.EncodeDate(2021,02,08);
else if (week == 7) Q.EncodeDate(2021,02,15);
else if (week == 8) Q.EncodeDate(2021,02,22);
else if (week == 9) Q.EncodeDate(2021,03,01);
else if (week == 10) Q.EncodeDate(2021,03,08);
else if (week == 11) Q.EncodeDate(2021,03,15);
else if (week == 12) Q.EncodeDate(2021,03,22);
else if (week == 13) Q.EncodeDate(2021,03,29);
else if (week == 14) Q.EncodeDate(2021,04,05);
else if (week == 15) Q.EncodeDate(2021,04,12);
else if (week == 16) Q.EncodeDate(2021,04,19);
else if (week == 17) Q.EncodeDate(2021,04,26);
else if (week == 18) Q.EncodeDate(2021,05,03);
else if (week == 19) Q.EncodeDate(2021,05,10);
- Give the variable a Label and Name under Properties > GENERAL.
- Finally, change the variable Structure to Date/Time to use it as a date variable set.
- Click Calculate.