Character
[][] My[] pats[]
$w. INPUT animala $10. My[]pats
NUMERIC 120 9.9
w.d number 3. PRICE 3.1 dollar COMMA6. /* allow comma to separate normal values
DATES
DDMMYYw. 28/01/61 DDMMYY8. 28/01/1961 DDMMYY /* take up 8 spaces
MMDDYw. 01/01/61 MMDDYY8. 01-01-1961
data grades;
input name $9. quiz exam project $2. absences;
datalines;
Ann 81 90 A- 0
Bill 78 84 B 0
Catherine 95 89 A 1
David 84 88 B+ 1
;
run;
/* allows Catherine to have an adequate amount of spaces as default is eight characters, but Catherine is 9 so $9. provides the correct amount of spaces */
/*otherwise Catherine gets cut off to Catherin */
data grades;
input name $CHAR9. quiz exam project $CHAR2. absences;
datalines;
Ann 81 90 A- 0
Bill 78 84 B 0
Catherine 95 89 A 1
David 84 88 B+ 1
;
run;
/*here the lead missing for Bill is retained in the dataset but not generated in the output results*/
so output changes
DATA CRIME DATASET
data crimes;
input state $14. @16 violent comma5.0 murder 4.1 metro percent5.;
FLORIDA 1,206 89 93.0%
GEORGIA 723 114 67.7%
/*
Load a state with up to 15 characters
at spot 16 get ready for violent data which is a numerical variable with a comma with 5 spaces and no decimals
murder is a numeric with one decimal
metro is a percentage up to 5 characters long*/
print contents
proc contents data = crime positions;
quit;
print dataset
proc print data = crime;
quit;
/* see that print out in metro does not show percent mark, just know that its a percent*/
what if?
data crimes;
input state $14. @16 violent comma5.0 murder 4.1 metro percent5.;
FLORIDA 1,206 8.9 93.0%
GEORGIA 723 114 67.7%
Looking at Output
Georgia and below do not have decimals, so see of decimal output is forced…even when not needed
does it work if you end each whole number with a point 0? —> No bc SAS isn’t reading numbers, its reading spots
FIX issue by taking out florida’s decimal
WORKING WITH DATE FORMATS
data schedule;
input @1 gameday mmddyy8. @9 location @1 $1. @10 opponent $14. @25
gametime time5. @31 team 0;
datalines;
/*
column 1 —> loading game day in
month, day, and year up to eight characters
at column 9 —> and only column 9 list if game is home or away—> if away state with @ symbol
load the location up to one character long
at the missing space load the @ to indicate an away game
at column 10—> list the opponent’s name and know that the name may be up to 14 character’s long
at column 25 —> Variable game time
know that its in time format up to 5 variables long
at column 31 —> lists team (which team which is the sport team gender)
proc print game
Goffy outputs are gametimes and gamedays —> bc game day is numerical value for the number days from Jan 1st 1960
gametime is saved as the number of seconds until midnight
So write times with a format function
proc print data= schedule;
format gameday DATE9.; /*dayMONTHyear 01JAN1988*/
format gametime times5.; /*times in military time*/
quit;
Changing date to
proc print data= schedule;
format gameday DATE11.; /*dayMONTHyear 01JAN1988*/
format gametime times5.; /*times in military time*/
quit;
Change date mmddyy10 and time to am and pm measures
proc print data= schedule;
format gameday mmddyy10.; /**/
format gametime timeampm11.; /*times in am and pm time*/
quit;
formating 12 o clock hour with
proc print data= schedule;
format gameday mmddyy10.; /**/
format gametime timeampm7.; /*times in am and pm time*/
quit;
formating 12 o clock with minutes ~ gives enough characters for 00 minutes
proc print data= schedule;
format gameday mmddyy10.; /**/
format gametime timeampm9.; /*times in am and pm time*/
quit;
if you want labels in the print out
proc print data = baseline LABEL;
run;
If you want a print out with an observation counter
proc print data = baseline LABEL NOOBS;
run;
If you only want only one observation printed
proc print data = baseline (OBS =1) LABEL;
run;
proc print data = baseline (OBS=1) LABEL NOOBS;
run;
What if you didnt want to start at first observation
proc print data = baseline (FIRSTOBS=2) LABEL NOOBS;
run;
/*prints the second person/observation */
proc print data = baseline (FIRSTOBS=2, OBS =5) LABEL NOOBS;
run;
/* starts at Kentucky and prints a total of 4 observations (starting at two to observation 5) */
proc print data = baseline (FIRSTOBS=2, OBS=10) LABEL NOOBS;
run;
/* starts at 2 to up to 9 observations (cuts out first observation) */