I’ve been reminded of how we can take advantage of the @ and @@ in SAS when entering data. There have been a few students using this code, which I think is wonderful, and something I’d like to revisit and maybe remind folks on what these symbols do and how we can use them.
We will revisit a previous session we did a number of years ago on this very topic. Hope to see you next Friday, February 16 to discuss Tips and Tricks: @ and @@
Follow-up Question and Code
A great situation for demonstration purposes was suggested in the session today. Using the sheep dataset we have, but now we have measures for 2 weeks:
CageID Trmt A1_wk1 A2_wk1 A3_wk1 A4_wk1 A1_wk2 A2_wk2 A3_wk2 A4_wk2
101 DietA 5 8 9 6 12 13 14 12
Can we use SAS to read this data into a dataset that would show:
CageID, Trmt, Week, Animal, Fibre
Try this out! A do-loop within a do-loop all within an INPUT statement. See the placement of the “@”
Data fibretrial;
input CageID Treatment $ @;
do week = 1 to 2;
do animal = 1 to 4;
input fibre @;
output;
end;
end;
datalines;
101 DietA 5 8 9 6 12 13 14 12
102 DietA 6 7 8 5 12 14 15 21
201 DietB 10 9 11 14 22 21 24 25
202 DietB 15 12 11 10 23 25 26 27
;
Run;
One thought on “Revisit: How do we use @ and @@ to enter data”