Documente Academic
Documente Profesional
Documente Cultură
BASICO
Giampaolo Orlandoni M. M Josefa Ramoni P.
INTRODUCCION AL SAS
1. 2. 3. 4 4. 5. 6 6. Estructura SAS Paso de Datos: Data Paso de Procedimientos: Proc Entrada de Datos: Input, Input Infile, Infile Import Formato de Datos: Lista, Columna, Formato Procedimientos: 1. Proc Print 2. Proc Sort 3. Proc Contents 7. Creacin de Archivos permanentes: Libname 8. Ejercicios
1. PASODEDATOS( (DATASTEP) )
DATA nombre; INPUT variables numricas y caracteres; DATALINES; {datos} ; RUN;
1. PASODEDATOS(DATASTEP)
Data Venta; Inp t anio ventas Input entas costo costo; Datalines; 1991 12132 1100 1992 19823 1100 1993 16982 1200 1994 18432 1200 1995 19432 1200 ; Run;
2. PASODEPROCEDIMIENTO(PROCSTEP)
2.1 Proc Print data=venta; Title 'Reporte Reporte 1 1'; ; run; Proc Print data=venta; Var anio ventas; Title 'Reporte Reporte 2 2'; ; run; Proc P P Print i d data=venta; By costo; ; Var anio ventas; Title 'Reporte 3'; run;
2.2
2 3 2.3
FormaGeneraldePROCPRINT
variables;
Var variables;
1_Ej1.sas
1-Leer 1 Leer los datos 2-Imprimir datos 3-Imprimir p Ao y Ventas, por Costo 4-Usar ttulos
Data venta; Input anio ventas costo; Datalines; ; 1991 12132 1100 1992 19823 1100 1993 16982 1200 1994 18432 1200 1995 19432 1200 ; run; Proc Print data=venta; title 'Reporte 1 '; run; Proc Print data=venta; Var anio ventas; title 'Reporte Reporte 2 '; ; run; Proc Print data=venta; y costo; ; By Var anio ventas; title 'Reporte 3 '; run;
1_Ej2.sas
1-Leer los datos 2-Calcular variable Beneficio 2-Imprimir datos 3 I 3-Imprimir i i A Ao, Ventas, Beneficio por Costo. Costo
Data venta; Input anio ventas costo; Datalines; 1991 12132 1100 1992 19823 1100 1993 16982 1200 1994 18432 1200 1995 19432 1200 ;
Proc Print data=venta; title 'Reporte 1 '; run; Proc Print data=venta; Var anio ventas beneficio; title 'Reporte Reporte 2 '; ; run; Proc Print data=venta; By costo; Var anio ventas beneficio; title 'Reporte 3 '; run;
1_Ej3.sas
Proc Print Data=venta Split='*'; Label ventas='Ventas * Ao costo='Costo ben='Beneficio antes *Impuesto'; Format ventas costo ben dollar10.1; Id an; Sum ventas costo ben; Title 'PRINT con Totales'; run;
BY variable(s); FOOTNOTE<n> <'footnote'>; FORMAT variable(s) format-name; ID variable(s); ( ); LABEL variable='label'; PAGEBY variable; SUM variable(s); ariable(s) SUMBY variable; TITLE<n> <'title'>; VAR variable(s); WHERE where-expression;
SUM variable(s): Identifies the numeric variables to total in the report. When also use the BY statement, the SUM statement produces subtotals each time the value of a BY variable changes. SUMBY variable: Limits the number of sums that appear in the report. PROC PRINT reports totals only when variable changes value or when any variable that is listed before it in the BY statement changes value value. Must use a BY statement with the SUMBY statement. WHERE where-expression: p Subsets the input data set by identifying certain conditions that each observation must meet before an observation b ti i available is il bl for f processing. i Where-expression defines the condition. The condition is a valid arithmetic or logical expression that generally consists of a sequence of operands and operators.
1_Ej2-1.sas
Qu sucede si hay algn dato faltante en alguna de las variables? Correr el programa con un dato faltante para el costo del ao 1993. Indicar al SAS que ese dato es faltante con (.) Efectos. 1993 16982
Data venta; Input anio ventas costo; Beneficio = ventas - costo; Datalines; 1991 12132 1100 1992 19823 1100 1993 16982 1994 18432 1200 1995 19432 1200 ; Proc Print data=venta; title 'Reporte 1 '; run; Proc Print data=venta; ; Var anio ventas beneficio; title 'Reporte 2 '; run; Proc Sort data=venta; by costo; run; Proc Print data=venta; By costo; Var anio ventas beneficio; title 'Reporte 3 '; run;
LecturadeDatos
1.
INPUT
Nombra las variables del conjunto de datos que q e el programa debe leer leer. Informa la ubicacin de los valores de las variables del conjunto de datos. Modos de lectura: 1. Input Lista: 2. Input Columna: 3. Input Formato: formato libre formato fijo informats
INPUT
Caractersticas FormatoLibre:datos q quenoestnencolumnas fijas.Estnseparadosporespaciosblancos Delimita loscamposconespaciosblancos ($) ) Leedatosnumricosocaracteres( Longitudnombre:8caracteres Leedatosfaltantesindicadosconpunto(.) Noleecaracteresconblancosintercalados Especificacindelinicioyfindelacolumnadela variable (datosencolumnasfijas) Especificalaposicindelacolumna luegodel nombredelavariable Leevariablescaracter,usando$luegodel nombredelavariable Permitedarinstruccionesespecficas: Informatname w.d wespecifica ifi ancho h d decampo( (opcional) i l) . delimitadorobligatorio ddgitosdecimales(opcional)
Modificadores
$ leecaracteres & leecaracterescon blancosintercalados :usaformatoyse detienealsiguiente espacioblanco
LISTA
COLUMNA
FORMATO
J P L A A
1 2 3 4 5 6 7 8
U E U L L
A D I F I
N R S R C
9 0 1 2 3 4 5
O A E D O I A
M M F M F
1 1 1 1 1
2 4 3 5 5
1 1 1 1 1
5 6 4 5 5
0 0 0 8 0
8 9 0
4 5 4 4 4
0 0 2 8 7
COLUMNA
INPUT Nombre $ 1-8 Sexo $ 11 Edad 13-14 Altura 16 16-18 18 Peso 20 20-21; 21;
FORMATO
INPUT Nombre $8. $8 @11 Sexo $1 $1. +1 Edad 2 2. +1 Altura 4. +1 Peso 3.;
Input Columna
Data nombres; INPUT Nombre $ 1-8 Sexo $ 11 Edad 13-14 Altura 16-18 Peso 20-21; datalines; juan m 12 150 40 pedro m 14 160 50 luisa f 13 140 42 alfredo m 15 158 48 alicia f 15 150 47 ; proc print; run;
C l Columna Obs 1 2 3 4 5 18 11 13 14 16-18 13-14 16 18 20-21 20 21 Nombre Sexo Edad Altura Peso juan j pedro luisa alfredo alicia m m f m f 12 14 13 15 15 150 160 140 158 150 40 50 42 48 47
2 Modificador @@ 2-Modificador
Permite seguir g leyendo y variables en un mismo registro Debe ser el ltimo elemento del INPUT.
Eldoble @@(doubletrailing@): Evita que leaunnuevo registro cuando encuentra unnuevo INPUT Evita que sesuelte elregistro cuando elprograma regresa alinicio del DATAstep. Ejemplo
Data Set Creado con @@:
Obs Sexo Obesidad 1 2 3 4 5 6 m f m f m m 13.3 22.0 22.0 23.2 16 0 16.0 12.0
Data obeso; I Input t Sexo S $ Obesidad Ob id d @@; datalines; m 13.3 f 22 m 22 f 23.2 m 16 m 12 ; proc print data=obeso; run;
2.
INFILE
Permite leer archivos de datos externo, en formato ASCII. Se ubica entre las sentencias DATA e INPUT:
Data nombre; INFILE c:\DataSAS\Archivo.dat; Input var1 var2 .... varn;
Opcin MISSOVER: asigna valor faltante a datos que no tienen el smbolo (.)
Data nombre; INFILE c:\DataSAS\Archivo.dat MISSOVER; Input I t var1 1 var2 2 .... varn;
2.
/* Definir archivos permanentes SAS; Uso de LIBNAME libname ventas 'c:\DataSas\dat'; ods html file= 'c:\DataSAS\html\1 c:\DataSAS\html\1_LibVenta.html LibVenta html'; ; data ventas.TR1; INFILE 'C:\DataSas\dat\tr1.dat'; Input Depart $ Lugar $ Trim Ventas; proc print; run; /* Dos formas de leer el archivo TR1 */ / / /* 1-Indicando el Path completo */ Proc print data= 'c:\DataSAS\dat\TR1'; Var Ventas; run;
INFILE
*/
/* 2-Usando el nombre asignado por libname */ proc print data=ventas.TR1; var a t trim lugar uga depa depart t ventas; e tas; run; u ; ods html close; ..\..\..\..\..\..\..\DataSAS\html\1_LibVenta.html /*Definir archivos permanentes SAS; LIBNAME */ libname ventas 'c:\DataSas\dat'; NOTA: Libref VENTAS was successfully assigned as follows: Engine: V9 Physical Name: c:\DataSas\dat
2.
ARCHIVO TR1.dat con dato faltante en la variable ventas. U Usar MISSOVER para l leer correctamente t t l los d datos. t Partes Partes Partes Repar Repar Repar Herram Herram Herram Sydney Atlanta Paris Sydney Atlanta Paris Sydney Atlanta Paris 1 1 1 1 1 1 1 1 1 4043.97 6225.26 3543.97 5592.82 9210.21 8591 98 8591.98 1775.74 5914.25
data ventas.TR1; INFILE 'C:\DataSas\dat\tr1.dat' MISSOVER; Input Depart $ Lugar $ Trim Ventas; proc print; run;
3. Proc IMPORT
Permite leer archivos de datos externo, en cualquier formato: ASCII, xls, dbf, csv. Se puede ejecutar por comandos: Archivo c o Importar po ta Datos atos PROC IMPORT statement arguments: g DATAFILE= OUT= DBMS= REPLACE Data source statements: DELIMITER= DELIMITER GETNAMES=
Proc IMPORT
proc import datafile= 'C:\DataSas\importarTab.dat' out=misDatosTab dbms=dlm replace; getnames yes; getnames=yes; run; proc print data=misDatosTab; run; ods html file="datosTab.html"; proc print; run; ; ods html close;
Obs 1 2 3 4 5 6 7 Region Sur Sur Sur Nor Nor Sur Nor Estado AZ BL BR MR FC AP AZ Mes JAN01 FEB01 FEB01 FEB01 MAR01 MAR01 MAR01 Gasto 2000 1200 8500 3000 6000 9800 1500 Ingreso 8000 6000 11000 4000 5000 13500 1000
Proc Sort:OrdenarDatos
PROC SORT <DATA=SAS-data-set>; BY variable(s);
PROC SORT DATA DATA=SAS-data-set: SAS data set: ordena un SAS DS segn los valores de variables listadas en el BY. BY variable(s): Especifica las variables por las que PROC
SORT ordena las observaciones del archivo. archivo PROC SORT ordena el DS en orden ascendente.
Data venta; Input an mes $ ventas costo; Beneficio = ventas - costo; D t li Datalines; 1991 ene 12132 1200 1992 feb 19823 1100 1993 993 e ene e 16982 698 1200 00 1994 feb 18432 1100 1995 ene 19432 1200 ; run;
Proc Print data=venta; By mes; Var an ventas costo beneficio; titl 'Reporte title 'R t M Mes ' '; run; Proc Print data=venta; y mes costo; ; By Var an ventas beneficio; title 'Reporte Mes_Costo ; run;
1_Ej5.sas
Input Libre Variables caracteres Datos faltantes marcados con (.) Blancos intercalados Modificadores $: caracteres &: blancos intercalados
ods html file='c:\DataSas\Clase.html'; *Paso 1: Crear un archivo de datos SAS; Data clase; Input nombre $ sexo $ edad origen & $12.; *Paso 2:
datalines; alfredo alicia barbara henry lucia juan saul pablo luis
Lectura de observaciones;
M F F M F M M M M 14 14 14 15 15 16 16 15 16 Merida . Caracas Pto Cabello . Valencia Caracas Pto Cruz Merida
; p con los datos SAS; ; * Paso 3: Operar Proc Print; title 'Datos Clase'; run; Proc Sort; By sexo edad; run; Proc Print data=clase; By sexo edad; run; ods html close;
1_Ej6.sas
Lectura Matriz de C Correlacin l i
ods html file='c:\DataSas\1_Ej6.html'; DATA D1(TYPE D1(TYPE=CORR) CORR) ; INPUT _TYPE_ $ _NAME_ $ Datalines;
N STD CORR CORR CORR CORR CORR CORR CORR CORR CORR CORR CORR CORR ;
V1-V12;
. 300 300 300 300 300 300 300 300 300 300 300 300 . 2.48 2.39 2.58 3.12 2.80 3.14 2.92 2.50 2.10 2.14 1.83 2.26 V1 1.00 . . . . . . . . . . . V2 .69 1.00 . . . . . . . . . . V3 .60 60 .79 79 1 1.00 00 . . . . . . . . . V4 .62 .47 .48 1.00 . . . . . . . . V5 .03 .04 .16 .09 1.00 . . . . . . . V6 .05 -.04 .08 .05 .91 1.00 . . . . . . V7 .14 14 .05 05 .06 06 .12 12 .82 82 .89 89 1 1.00 00 . . . . . V8 .23 .13 .16 .21 .70 .72 .82 1.00 . . . . V9 -.17 -.07 -.04 -.05 -.33 -.26 -.38 -.45 1.00 . . . V10 -.10 -.08 .07 .15 -.16 -.20 -.27 -.34 .45 1.00 . . V11 -.24 24 -.19 19 -.26 26 -.28 28 -.43 43 -.37 37 -.53 53 -.57 57 .60 60 .22 22 1 1.00 00 . V12 -.11 -.07 .07 .08 -.10 -.13 -.23 -.31 .44 .60 .26 1.00
1_Ej7.sas
1_Ej8.sas
Lectura de un archivo dos veces, luego d una de condicin if Subconjunto de datos creado con el smbolo @
ods html file='c:\DataSas\1_Ej8.html'; DATA Ej8; INPUT equipo $ 13-16 @; IF equipo='rojo'; INPUT idn 1 1-4 4 pesoi 20 20-23 23 pesof 24 24-26; 26; redpeso=pesoi-pesof; Datalines; 1023 David rojo 189 165 1049 Amelia A li azul l 145 124 1219 Alan rojo 210 192 1246 Raul azul 194 177 1078 Alicia rojo j 127 118 1221 Juan azul 220 . ; Proc Print data=Ej8; run; PROC CORR DATA=Ej8 NOMISS; VAR pesoi pesof redpeso; run; ods html close;
1_Ej9.sas
Creacin de mltiples observaciones a partir ti d de un registro Data set creado con el smbolo @@
ods html file='c:\DataSas\1_Ej9.html'; DATA Ej9; INPUT sexo $ edad peso @@; Datalines; m 13 30 f 22 75 f 18 70 m 22 70 f 23 78 m 20 65 m 16 50 m 12 25 f 19 73 ; run; Proc Print; run; Proc Sort; By sexo; run; ; Proc print data=Ej9; By sexo; run; PROC CORR DATA=Ej9 NOMISS; VAR edad peso; run; ods html close;
1_Ej10.sas
DATA Info; INPUT Nombre $15. $15 /Direccion $20. $20 /Ciudad_Estado Ciudad Estado $15. $15 /Zip $5 $5.; ; Datalines; Juan Sanchez Av Urdaneta Merida MR 05101 Luis Perez Av Rondon Barinas BR 02511
Calle Mario Porlamar NE 03356 ; run; Proc Print; title ' '; run; ods html close;
Librera de trabajo del Sas: C:\SAS\SASWORK Work.Ventas: archivo Ventas almacenado en Work
Con Herramientas se crea Nueva Librera y se indica: Nombre de la librera Ruta: direccin fsica de la librera
1_Ej11.sas
Libname C 'C:\DataSAS\'; ods html file='c:\DataSas\Lib3.html'; Data C.Ventas; I Input t Region R i $V Venta; t D t li Datalines;
R1 10 R3 20 R7 30 R2 40 R4 50 R6 60 R5 70 R1 30 R3 30 R7 50 R2 10 R4 80 R6 90 R5 50 R1 10 R3 20 R7 30 R2 40 R4 50 R6 60 R5 70 R1 30 R3 30 R7 50 R2 10 R4 80 R6 90 R5 50
1_Ej12.sas
/* Crear archivo permanente SAS */ libname ventas 'c:\DataSas\Venta2002'; Data ventas.TR1; Input Depart $ Lugar $ Trim Datalines;
Partes Partes Partes Repar Repar Repar Herram Herram Herram Sydney Atlanta Paris Sydney Atlanta Paris Sydney Atlanta Paris 1 1 1 1 1 1 1 1 1 4043.97 6225.26 3543 97 3543.97 5592.82 9210.21 8591.98 1775.74 2424.19 5914.25
Ventas;
/* Dos formas de leer el archivo TR1 */ /* 1-Indicando el Path completo */ Proc means data= 'c:\DataSAS\Venta2002\TR1'; Var Ventas; run; /* 2-Usando el nombre asignado por libname */ Proc Print data=ventas.TR1; var trim lugar depart ventas; run; Proc means data= ventas.TR1; Var Ventas; run;
1_Ej12.sas Libname
Libname C 'C:\DataSAS\'; ods html file file='c:\DataSas\VentaLib3 c:\DataSas\VentaLib3.html html'; ; Proc Sort Data= C.Ventas By y Region; g ; Data C.Totales(Keep=Region Total); Set C.VentasOrd; By Region; If First.Region then Total=0; Total+Venta; If Last.Region; Proc Print Data=C.Totales Noobs; Title 'Total Ventas 2000'; run; ods html close; Out=C.VentasOrd;
Lista alfabtica de variables y atributos Nm 5 1 6 4 2 3 7 Variable Cantidad Mes Precio Tipo Trim Vendedor Venta Tipo Numrica Alfanumrica Numrica Alfanumrica Alfanumrica Alfanumrica Numrica Longitud 8 8 8 16 8 14 8
EJERCICIOS
EJERCICIO1: Monto de multas de trfico por estado (USA). Imprimir el archivo de datos ordenado por monto y por estado. estado EJERCICIO2: Imprimir el archivo de datos ordenados por ventas, departamento, vendedor. Calcular t t l totales d venta de t por Departamento, D t t por Vendedor V d d EJERCICIO3: Lectura de Datos con diferentes formatos EJERCICIO4: Ventas por departamento y vendedor. vendedor Calcular comisiones por ventas. Tablas Frecuencia de ventas. Total comisiones por vendedor y por departamento EJERCICIO5: Creacin de Libreras permanentes. Datos climticos. y Archivos
1_Ejercicio1.Monto
de multas de trfico por estado (USA). Imprimir el archivo de datos ordenados por monto y por estado
ods html file='c:\DataSas\Ejer1.html'; Data Ejer1; Input Estado $ Monto @@; Datalines; AL 100 HI 200 DE 20 IL 1000 AK 300 CT 50 AR 100 IA 60 FL 250 KS 90 AZ 250 IN 500 CA 100 LA 175 GA 150 MT 70 ID 100 KY 55 CO 100 ME 50 NE 200 MA 85 MD 500 NV 1000 MO 500 MI 40 NM 100 NJ 200 MN 300 NY 300 NC 1000 MS 100 ND 55 OH 100 NH 1000 OR 600 OK 75 SC 75 RI 210 PA 46.50 TN 50 SD 200 TX 200 VT 1000 UT 750 WV 100 VA 200 WY 200 WA 77 Wi 300 DC. DC ; run; ods html close;
1_Ejercicio2.
Ventas por departamento y vendedor: Imprimir el archivo de datos ordenados por ventas, departamento, vendedor. Calcular totales de venta por Departamento, por Vendedor ods html file='c:\DataSas\Ejer2.html'; \ \ j ; Data Ejer2; Input Vendedor Departamento Ventas; Datalines;
V1Ropa V2Zapatos V3Ropa V4Zapatos V3Ropa V3Zapatos V1Ropa V2Zapatos V2Ropa V1Zapatos V1Ropa V2Zapatos V3Zapatos V4Zapatos V3Zapatos V4Ropa 10.5 10 5 12.6 20.1 18.6 17 3 17.3 16.0 15.2 11.8 13 3 13.3 19.1 21.5 30.2 28 5 28.5 26.2 27.6 30.0
1_Ejercicio 4. Ventas por departamento y vendedor 1-Calcular comisiones por ventas. Comisin: 5% de las ventas de ropa 7% de las ventas de zapatos
Ejemplo 1
ods html file='C:\DataSas\html\1_Fecha1.html'; Data fecha; Hora1=86399; format Hora1 datetime.; Fecha1=86399; format Fecha1 date.; date ; Hora2=86399; format Hora2 timeampm.; Fecha1Mes=month(Fecha1); run; Proc Print data=fecha noobs; title 'Mismo Nmero, , Diferentes Valores SAS'; ; footnote1 'Hora1 es SAS DATETIME'; footnote2 'Fecha1 es SAS DATE '; footnote3 'Hora2 es SAS TIME '; footnote4 'Fecha1Mes es el mes de Fecha1'; run; title; f titl footnote; t t ods html close;
Ejemplo 1
Hora1 01JAN60:23:59:59
Fecha1 20JUL96
Hora2 11:59:59 PM
Fecha1Mes 7
Ejemplo 2
ods d ht html l fil file='C:\DataSas\html\1_Fecha2.html'; 'C \D t S \ht l\1 F h 2 ht l' Data Reunion; Input p Region g $ Reunion : mmddyy10.; yy ; mail_envio = Reunion-45; datalines; N 11-24-11 11 24 11 S 12-28-11 E 12-03-11 W 10-04-11 ; run; proc print data=reunion noobs; format reunion mail_envio date9.; title 'Cronograma Envio @mail'; run; title; ods html close;
Ejemplo 2
ods html file= file='C:\DataSas\html\1 C:\DataSas\html\1_Fecha2.html Fecha2 html'; ; \DataSAS\html\1 Fecha2 html \DataSAS\html\1_Fecha2.html
Regin N S E W
Ejemplo 3
1-file='C:\DataSas\sas\1_Fecha3.sas'; \DataSAS\sas\Dia1bcv_IntroduccionSAS\1_Fecha3.sas 2-ods html file='C:\DataSas\html\1_Fecha3.html'; \DataSAS\html\1_Fecha3.html
Obs 1 2 3 4
IniFecha
FinFecha
Duracion 16 47 62 7
Ejercicios: Correr los Data Steps que se presentan a continuacin. Analizar los formatos. Verificar posibles errores. Corregir errores.
1-Crear el Data Set USCLIM.HURRICANE data usclim.hurricane; Input Estado Fecha Muertes Perdida Nombre; format Fecha worddate18. Costo dollar6.; informat Estado $char11. $char11 Fecha date9 date9.; ; label Perdida=Costo'; datalines; Mississippi 14aug69 256 1420 Camille Florida o da 14jun72 ju 117 2100 00 Agnes g es Alabama 29aug79 5 2300 Frederick Texas 15aug83 21 2000 Alicia Texas 03aug80 28 300 Allen ;
1-DATA Step para crear el Data Set USCLIM.HURRICANE libname usclim 'C:\DataSAS'; data usclim.huracan; input @1 Estado $char11. @13 Fecha date7. Muertes Perdida Nombre $; format Fecha worddate18. Perdida dollar6.; informat Estado $char11. $char11 Fecha date9 date9.; label Millions='Dao'; datalines; pp 14aug69 g 256 1420 Camille Mississippi Florida 14jun72 117 2100 Agnes Alabama 29aug79 5 2300 Frederick Texas 15aug83 21 2000 Alicia Texas 03aug80 28 300 Allen ; Obs Estado Fecha Muertes Perdida Nombre Proc print; run;
1 Mississippi pp August g 14, 1969 2 3 4 5 Florida June 14, 1972 256 117 5 21 28 $1,420 $2,100 $2,300 $2,000 $300 Camille Agnes Frederic Alicia Allen
Alabama August 29, 1979 Texas August 15, 1983 Texas August 3, 1980
2- Crear el Data Set USCLIM.LOWTEMP data usclim.lowtemp; Input Estado $char14. $char14 Ciudad $char14. $char14 Temp_F Temp F Fecha $ Elevacion; datalines;
Alaska Prospect Creek -80 23jan71 1100 Colorado Maybell -60 01jan79 5920 Idaho Island Prk Dam -60 18jan43 6285 Minnesota Pokegama Dam -59 16feb03 1280 North Dakota Parshall -60 15feb36 1929 South Dakota McIntosh -58 17feb36 2277 Wyoming Moran -63 09feb33 6770 ;
3- Crear el Data Set USCLIM.TEMPCHNG data usclim.tempchng; input @1 Estado $char13. @15 Fecha date7. Tem_In Tem_Fn Minutos; Diff= Tem_Fn Tem_In ; informat estado $char13. Fecha date7.; format Fecha date9.; datalines;
North South South South South Dakota Dakota Dakota Dakota Dakota 21feb18 22jan43 12jan11 22jan43 10jan11 -33 50 720 -4 4 45 2 49 -13 120 54 -4 27 55 8 15 ;
libname clima 'C:\DataSAS'; 4-Crear el Data Set CLIMA.HIGHTEMP data clima.hightemp; clima hightemp; input Sitio $ 1-13 Fecha $ tem_F tem_C; datalines; Libya 13sep22 136 58 California 10jul13 134 57 Israel 21jun42 129 54 Argentina 11dec05 120 49 Saskatchewan 05jul37 113 45 ; 5-Crear el Data Set CLIMA.LOWTEMP data clima.lowtemp; input Sitio $ 1-13 Fecha $ datalines; ; Antarctica 21jul83 -129 -89 Siberia 06feb33 -90 -68 Greenland 09jan54 -87 87 -66 66 Yukon 03feb47 -81 -63 Alaska 23jan71 -80 -67 ; tem_F tem_C;
6-Crear el Data Set PRECPITA.RAIN data precpita.rain; input Sitio $ 1-12 1 12 @13 Fecha date7. date7 Inch Cms; format Fecha date9.; datalines; L R La Reunion i 15 15mar52 52 74 188 Taiwan 10sep63 49 125 Australia 04jan79 44 114 Texas 25jul79 43 109 Canada 06oct64 19 49 ; 7-Crear el Data Set PRECPITA.SNOW data precpita.snow; input Sitio $ 1 1-12 12 @13 Fecha date7. Inch Cms; format Fecha date9.; datalines; Colorado 14apr21 76 193 Alaska 29dec55 62 158 France 05apr69 68 173;
8-DATA Step to Create the Data Set STORM.TORNADO lib libname storm t 'SAS-data-library'; 'SAS d t lib ' data storm.tornado; input Estado $ 1-12 @13 Fecha date7. Muertes Perdida; format Date date9. Perdida dollar6.; label Perdida=Costo en Millones'; datalines; Iowa 11apr65 257 200 Texas 11may70 26 135 Nebraska 06may75 3 400 Connecticut 03oct79 3 200 Georgia 31mar73 9 115 ;
SAS/ASSIST