| 1 | <h2>Comments</h2> |
| 2 | <pre><code>/* This is a |
| 3 | multi-line comment */ |
| 4 | |
| 5 | * This is a comment too;</code></pre> |
| 6 | |
| 7 | <h2>Numbers, dates and times</h2> |
| 8 | <pre><code>42; 4.5; 4.5e-10; -3; -3.5e2; -4.2e-23; |
| 9 | 0afx; 0123x; |
| 10 | '1jan2013'd; '01jan09'd; |
| 11 | '9:25't; '9:25:19pm't; |
| 12 | '01may12:9:30:00'dt; '18jan2003:9:27:05am'dt; |
| 13 | '2013-05-17T09:15:30–05:00'dt; '2013-05-17T09:15:30–05'dt; |
| 14 | '2013-07-20T12:00:00+00:00'dt; '2013-07-20T12:00:00Z'dt;</code></pre> |
| 15 | |
| 16 | <h2>Strings</h2> |
| 17 | <pre><code>'Single quoted string'; |
| 18 | "Double quoted string"; |
| 19 | 'String ''quoted'' string "containing" quote'; |
| 20 | "Double ""quoted"" string 'containing' quote";</code></pre> |
| 21 | |
| 22 | <h2>Operators</h2> |
| 23 | <pre><code>A**B; |
| 24 | 'foo'||'bar'!!'baz'¦¦'test'; |
| 25 | A<>B><C; |
| 26 | A~=B¬=C^=D>=E<=F; |
| 27 | a*b/c+d-e<f>g&h|i!j¦k; |
| 28 | ~a;¬b;^c; |
| 29 | (a eq b) ne (c gt d) lt e ge f le h; |
| 30 | state in ('NY','NJ','PA'); |
| 31 | not a;</code></pre> |
| 32 | |
| 33 | <h2>More examples</h2> |
| 34 | <pre><code>/* Some examples adapted from the documentation |
| 35 | http://support.sas.com/documentation/cdl/en/basess/64003/PDF/default/basess.pdf */ |
| 36 | |
| 37 | data city; * another inline comment; |
| 38 | |
| 39 | input Year 4. @7 ServicesPolice comma6. |
| 40 | @15 ServicesFire comma6. @22 ServicesWater_Sewer comma6. |
| 41 | @30 AdminLabor comma6. @39 AdminSupplies comma6. |
| 42 | @45 AdminUtilities comma6.; |
| 43 | ServicesTotal=ServicesPolice+ServicesFire+ServicesWater_Sewer; |
| 44 | AdminTotal=AdminLabor+AdminSupplies+AdminUtilities; |
| 45 | Total=ServicesTotal+AdminTotal; |
| 46 | |
| 47 | Test='A string '' whith a quote'; |
| 48 | Test2 = "A string "" whith a quote"; |
| 49 | |
| 50 | label Total='Total Outlays' |
| 51 | ServicesTotal='Services: Total' |
| 52 | ServicesPolice='Services: Police' |
| 53 | ServicesFire='Services: Fire' |
| 54 | ServicesWater_Sewer='Services: Water & Sewer' |
| 55 | AdminTotal='Administration: Total' |
| 56 | AdminLabor='Administration: Labor' |
| 57 | AdminSupplies='Administration: Supplies' |
| 58 | AdminUtilities='Administration: Utilities'; |
| 59 | datalines; |
| 60 | 1993 2,819 1,120 422 391 63 98 |
| 61 | 1994 2,477 1,160 500 172 47 70 |
| 62 | 1995 2,028 1,061 510 269 29 79 |
| 63 | 1996 2,754 893 540 227 21 67 |
| 64 | 1997 2,195 963 541 214 21 59 |
| 65 | 1998 1,877 926 535 198 16 80 |
| 66 | 1999 1,727 1,111 535 213 27 70 |
| 67 | 2000 1,532 1,220 519 195 11 69 |
| 68 | 2001 1,448 1,156 577 225 12 58 |
| 69 | 2002 1,500 1,076 606 235 19 62 |
| 70 | 2003 1,934 969 646 266 11 63 |
| 71 | 2004 2,195 1,002 643 256 24 55 |
| 72 | 2005 2,204 964 692 256 28 70 |
| 73 | 2006 2,175 1,144 735 241 19 83 |
| 74 | 2007 2,556 1,341 813 238 25 97 |
| 75 | 2008 2,026 1,380 868 226 24 97 |
| 76 | 2009 2,526 1,454 946 317 13 89 |
| 77 | 2010 2,027 1,486 1,043 226 . 82 |
| 78 | 2011 2,037 1,667 1,152 244 20 88 |
| 79 | 2012 2,852 1,834 1,318 270 23 74 |
| 80 | 2013 2,787 1,701 1,317 307 26 66 |
| 81 | ; |
| 82 | proc datasets library=work nolist |
| 83 | ; |
| 84 | contents data=city |
| 85 | ; |
| 86 | run; |
| 87 | |
| 88 | |
| 89 | data city3; |
| 90 | set city(firstobs=10 obs=15); |
| 91 | run; |
| 92 | |
| 93 | data services (keep=ServicesTotal ServicesPolice ServicesFire |
| 94 | ServicesWater_Sewer) |
| 95 | admin (keep=AdminTotal AdminLabor AdminSupplies |
| 96 | AdminUtilities); |
| 97 | set city(drop=Total); |
| 98 | run; |
| 99 | proc print data=services; |
| 100 | title 'City Expenditures: Services'; |
| 101 | run; |
| 102 | |
| 103 | data newlength; |
| 104 | set mylib.internationaltours; |
| 105 | length Remarks $ 30; |
| 106 | if Vendor = 'Hispania' then Remarks = 'Bonus for 10+ people'; |
| 107 | else if Vendor = 'Mundial' then Remarks = 'Bonus points'; |
| 108 | else if Vendor = 'Major' then Remarks = 'Discount for 30+ people'; |
| 109 | run; |
| 110 | proc print data=newlength; |
| 111 | var Country Vendor Remarks; |
| 112 | title 'Information About Vendors'; |
| 113 | run; |
| 114 | |
| 115 | libname mylib 'permanent-data-library'; |
| 116 | data mylib.departures; |
| 117 | input Country $ 1-9 CitiesInTour 11-12 USGate $ 14-26 |
| 118 | ArrivalDepartureGates $ 28-48; |
| 119 | datalines; |
| 120 | Japan 5 San Francisco Tokyo, Osaka |
| 121 | Italy 8 New York Rome, Naples |
| 122 | Australia 12 Honolulu Sydney, Brisbane |
| 123 | Venezuela 4 Miami Caracas, Maracaibo |
| 124 | Brazil 4 Rio de Janeiro, Belem |
| 125 | ; |
| 126 | proc print data=mylib.departures; |
| 127 | title 'Data Set AIR.DEPARTURES'; |
| 128 | run; |
| 129 | |
| 130 | data missingval; |
| 131 | length Country $ 10 TourGuide $ 10; |
| 132 | input Country TourGuide; |
| 133 | * lines is an alias for datalines; |
| 134 | lines; |
| 135 | Japan Yamada |
| 136 | Italy Militello |
| 137 | Australia Edney |
| 138 | Venezuela . |
| 139 | Brazil Cardoso |
| 140 | ; |
| 141 | |
| 142 | data inventory_tool; |
| 143 | input PartNumber $ Description $ InStock @17 |
| 144 | ReceivedDate date9. @27 Price; |
| 145 | format ReceivedDate date9.; |
| 146 | * cards is an alias for datalines; |
| 147 | cards; |
| 148 | K89R seal 34 27jul2010 245.00 |
| 149 | M4J7 sander 98 20jun2011 45.88 |
| 150 | LK43 filter 121 19may2011 10.99 |
| 151 | MN21 brace 43 10aug2012 27.87 |
| 152 | BC85 clamp 80 16aug2012 9.55 |
| 153 | NCF3 valve 198 20mar2012 24.50 |
| 154 | KJ66 cutter 6 18jun2010 19.77 |
| 155 | UYN7 rod 211 09sep2010 11.55 |
| 156 | JD03 switch 383 09jan2013 13.99 |
| 157 | BV1E timer 26 03aug2013 34.50 |
| 158 | ; |
| 159 | run;</code></pre> |