webinar@lunchtime - sas...sas national languagesupport (nls) formate konvertieren datumsangaben in...
Post on 13-Apr-2020
3 Views
Preview:
TRANSCRIPT
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
WEBINAR@LUNCHTIME
THEMA: „SAS DATUMSWERTE: ERSTELLEN EIGENER
DATUMSFORMATE LEICHT GEMACHT"
EVA-MARIA KEGELMANN
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
ModerationAnne K. Bogner-Hamleh
SAS Institute GmbH
Education Consultant
Xing-Profil:http://www.xing.com/profile/AnneKatrin_BognerHamleh?key=0.0
WEBINAR@LUNCHTIME HERZLICH WILLKOMMEN BEI WEBINAR@LUNCHTIME
Hinweise zum Ablauf des Webinars:
• Teilnehmer sind automatisch “stumm” geschaltet
• Sie können Nachrichten an den Moderator senden / Fragen stellen
• die Veranstaltung wird aufgezeichnet
TrainingEva-Maria Kegelmann
SAS Institute GmbH
Sr Technical Training Consultant
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
LERNZIELESAS DATUMSWERTE: ERSTELLEN EIGENER
DATUMSFORMATE LEICHT GEMACHT
• Verstehen, wie SAS Datumswerte definiert sind
• Wissen, wie Datumswerte länderspezifisch dargestellt werden können
• Lernen, wie man ein benutzerdefiniertes Datumsformat erstellen kann
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DATUMS- UND ZEITWERTE HISTORIE
• Datums- und Zeitwerte sind im SAS System besondere numerische Werte.
• Die “SAS-Zeitrechnung” beginnt am 01. Januar 1960.
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DEUTSCHE DATUMSFORMATE: GEHEN NOCH, ABER
5
FormatGespeicherter
WertAngezeigter Wert
DEUDFDE. 17854 18Nov2008
DEUDFWDX. 17854 18. November 2008
DEUDFWKX. 17854 Dienstag, 18. November 2008
DEUDFDN. 17854 3
DEUDFDWN. 17854 Dienstag
DEUDFMN. 17854 November
DEUDFMY. 17854 Nov08
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
NLS DATUMSFORMATE SIND JETZT AKTUELL
SAS National LanguageSupport (NLS) Formate konvertieren Datumsangaben in die in anderen
Ländern üblichen Formate
Einstellung der Sprache: OPTIONS LOCALE=xxx;
6
Format Locale Beispiel
NLDATEw.English_UnitedStates January 01, 1960
German_Germany 01. Januar 1960
NLDATEMNw.English_UnitedStates January
German_Germany Januar
NLDATEWw.English_UnitedStates Fri, Jan 01, 60
German_Germany Fr, 01. Jan 60
NLDATEWNw.English_UnitedStates Friday
German_Germany Freitag
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
EINSTELLUNG DES GEBIETSSCHEMAS: LOCALE=
Nicht zu verwechseln mit einer SAS-Sprachversion!
Stellt verschiedene länderspezifische Konventionen und Spracheinstellungen zurVerfügung
Umfasst:• Regeln für die Sortierung von Zeichenketten
• Formatierung von • Datumswerten, z. B.19.3.2014 (Deutschland), 03/19/14 (USA) • Zeitangaben (12-Std. mit AM/PM oder 24-Std.)• Zahlen (Dezimalpunkt oder –komma)• Währungskennzeichen
• Papiergröße (A4, letter,…)
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
EINSTELLUNG DES GEBIETSSCHEMAS: LOCALE=
Systemoption LOCALE= setzt länderspezifische Konventionen und Spracheinstellungen
• Beispiel: options locale=german_germany;
• Standardeinstellung: LOCALE= English_UnitedStates
• Andere Systemoptionen wie ENCODING, DFLANG, DATESTYLE und PAPERSIZE basieren auf LOCALE= , falls nicht explizit gesetzt!
Weitere ausgewählte Werte:
SAS Name Kurzbezeichnung Alias
German_Austria de_AT
German_Germany de_DE German bzw. de
German_Liechtenstein de_LI
German_Luxembourg de_LU
German_Switzerland de_CH
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DIE SYSTEMOPTION DFLANG
DFLANG=
Sprache für internationale
Ein- und Ausgabeformate für Datumswerte
Der Standardwert ist ENGLISH. Weitere ausgewählte Werte:
Finnish Spanish
Swedish French
Swiss_French German
Swiss_German
Beispiel: options dflang=german;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
BENUTZERDEFINIERTE DATUMSFORMATE
• Kein passendes SAS Standard-Datumsformat vorhanden?
• Erstellen Sie ein eigenes Datumsformat mit
PROC FORMAT und der PICTURE-Anweisung.
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
SZENARIO
• Das Einstellungsdatum der Angestellten soll im Format DD-MMMYYYY
angezeigt werden, z.B. 02-SEP2014
• Dafür gibt es kein SAS Standard-Ausgabeformat.
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
PROC FORMAT - PICTURE-ANWEISUNG
Die PICTURE-Anweisung in PROC FORMAT definiert ein Template für
Datenwerte.
PROC FORMAT;PICTURE formatnamevalue-range-set-1 <(picture-1-option(s) )>;
RUN;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DATUMSFORMATE: DATATYPE-OPTION
Die DATATYPE-Option für die PICTURE-Anweisung gibt an, dass das Format
für einen SAS-Datums-, SAS-Zeit-bzw. SAS-Datumszeit-Wert verwendet wird.
PROC FORMAT;PICTURE name
value-range-set-1 (DATATYPE=DATE | TIME | DATETIME); RUN;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DIREKTIVEN FÜR EINE PICTURE-ANWEISUNG
Direktive = % plus Buchstabe
Legen fest, welche Datumskomponenten wie angezeigt werden.
Groß-/Kleinschreibung hat unterschiedliche Bedeutung!
Beispiel:
Ergebnis: 02-SEP2014
Sprache: entspricht der LOCALE= Systemoption
proc format;
picture myfmt
low-high = '%0d-%b%Y '(datatype=date);
run;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
DIREKTIVEN FÜR DIE PICTURE-ANWEISUNG
Direktive Bedeutung Beispiel
%a Wochentag, abgekürzt Wed
%A Wochentag Wednesday
%b Monatsname, abgekürzt Jan
%<n>B Monatsname (Optional: n=Anzahl Zeichen) January
%d Tag im Monat (%0d: Mit führender Null) 1 bzw. 01
%e Tag im Monat 2-stellig, mit führendem Blank " 1“ bis 31
%m Monat als Zahl (%0m: Mit führender Null) 1 bzw. 01
%n Monat als Zahl 2-stellig mit führendem Blank " 1“ bis 12
%q Quartal als Zahl 1 bis 4
%Q Quartal als Text Quarter 1
%u Wochentag als Zahl (Montag=1– Sonntag=7) 1 bis 7
%V KW (%0V: mit führender Null). 1 bzw. 01bis 53
%y %Y Jahr, 2-stellig bzw. 4-stellig 14 bzw. 2014
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
LÄNGE DES ANGEZEIGTEN DATUM-FORMATES
Achtung:
verwenden Sie die DEFAULT= option, damit die Breite der Anzeige groß genug
ist! (bei Verwendung der DATATYPE= Option)
Ohne DEFAULT= :
Breite entspricht der Anzahl Zeichen rechts vom =.
Beispiel:
Ohne Default= wäre hier die Standardbreite = 8
proc format;
picture myfmt (default = 50)
low-high = '%0d-%b%Y'(datatype=date);
run;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
BENUTZERDEFINIERTES DATUMSFORMAT - BEISPIEL
• Ergebnis: 18. August 2014 - KW 34 - 3. Quartal
• Voraussetzung:
• options locale=german_germany;
proc format;
picture myfmt (default= 50)
low-high = '%0d. %B %Y - KW %V - %Q'
(datatype=date);
run;
Demo: EOT_Datumsformate_erstellen
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
BENUTZERDEFINIERTE DATUMSFORMATE VERWENDEN
Verwenden Sie genau wie bei Standardformaten die FORMAT-Anweisung, um
ein Format auf eine bestimmte SAS-Variable anzuwenden.
Allgemeine Form der FORMAT-Anweisung:
Beispiel:
FORMAT variable(s) format.;
proc print data=ia.empdata;format orderdate myformat.;
run;
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
BENUTZERDEFINIERTES DATUMSFORMAT – BEISPIEL 2
proc format;
value schachteldate
low -'31DEC1990'd = [year4.]
'01Jan1991'd-'31DEC1991'd =
[nldateyq.]
'01JAN1992'd- high =
[nldateym.];
run;
Darstellung von Datumswerten mit unterschiedlichen
Detaillierungsgraden / Formatierungen
Ergebnis:
Demo: EOT_Datumsformat_versch_Intervalle.sas
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
BENUTZERDEFINIERTES DATUMSFORMAT – BEISPIEL 3
proc format library = work;
value ueberlapp (multilabel)
'01jan1991'd - '31mar1991'd = '1. Quartal'
'01apr1991'd - '30jun1991'd = '2. Quartal'
'01jul1991'd - '30sep1991'd = '3. Quartal'
'01oct1991'd - '31dec1991'd = '4. Quartal'
'01jan1991'd - '30jun1991'd = 'Halbjahr I'
'01jul1991'd - '31dec1991'd = 'Halbjahr II';
run;
Darstellung von Datumswerten mit überlappenden
Bereichen: MULTILABEL-Option in der Value-Anweisung
Ergebnis:
Demo: EOT_Datumsformat_überlappende_Bereiche.sas
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
FRAGEN?
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
VIELEN DANK FÜR IHRE TEILNAHME
Interesse an weiterem Austausch?
• Diskutieren Sie mit uns in der XING-Gruppe Business Analytics mit SAS
• Sprechen Sie uns direkt an:education@ger.sas.com
WEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d .
NÄCHSTES WEBINAR@LUNCHTIMEWEBINAR@LUNCHTIME
Copyr i g ht © 2012, SAS Ins t i tu t e Inc . A l l r ights reser ve d . www.SAS.com
FOLIEN ZUM DOWNLOAD UNTER
WWW.SAS.DE/LUNCHTIME
WIE HAT IHNEN UNSER WEBINAR GEFALLEN?
top related