programmering/klog på sas netværk...• excel til sas • eksempler på import, ods, xlxs libname...

Post on 02-Oct-2020

1 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Programmering/Klog på SAS Netværk4/3-2020 - Aarhus

Copyright © SAS Inst itute Inc. A l l r ights reserved.

• Velkomst

• Nyheder i SAS • v. Frans Holm, SAS

• Fordele ved de forskellige editorer (display manager, EG, SAS Studio)• v. Barbara Olsen, SAS

• Vlatin1/9 vs. UTF8• Kodeeksempler på hvad det kan betyde for dit output

• v. Barbara Olsen, SAS

• Secure - hvad betyder det for din kode (sftp, https)• v. Sara Armandi, SAS

• Excel til SAS• Eksempler på Import, ODS, xlxs libname

• v. Sara Armandi, SAS

• Afslutning

• Frokost

• Hvordan koder man i Viya – lidt teori og eksempler? • v. Frans Holm, SAS

Dagsorden

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Hvorfor FANS?

• Netværk

• Vidensdeling

• Vise Nyheder

• Vise muligheder

• ”Best” Practice

• Inspiration

• Øge værdien & anvendelsen af SAS (ROI – ROY)

• Hyggeligt/sjovt/spændende

SAS

&

JER

Copyright © SAS Inst itute Inc. A l l r ights reserved.

LodtrækningVind en sas-ting

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Nyheder i SASFrans Holm (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Nyt fra SAS

• EG kursus - What's New

• 3 timer in-house eller on-site

• Ny e-bog : https://support.sas.com/en/books/free-books.html

• sas.com/fans-dk

• Folkemødet

• What’s new in SAS 9.4 M6…

• AD synkronisering – Microsoft opdatering

• SAS dag – hos jer

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Fordele ved de forskellige editorer (display manager, EG, SAS Studio)

Barbara Olsen (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Agenda

• Editors:

o SAS

o EG

o SAS Studio

o Notepad++(+)

o https://blogs.sas.com/content/sasdummy/2017/08/25/npp-with-sas/

Copyright © SAS Inst itute Inc. A l l r ights reserved.

PAUSEVi begynder igen kl. 10:15

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Vlatin1/9 vs. UTF8Barbara Olsen (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Agenda

• Encoding – hvor støder man på det?

• DBCS (DoubleByteCharacterSystem) (MBCS (MultiByteCharacterSystem)) vs SBCS (SingleByteCharacterSystem)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Encoding – hvor støder man på det?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Encoding – hvor støder man på det?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Encoding – hvor støder man på det?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Encoding – hvor støder man på det?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Encoding – hvor støder man på det?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

DBCS (MBCS) vs SBCS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

DBCS(MBCS) vs SBCS

Windows std. Wlatin-1 /Windows-1252

UnixLatin1

Unix (sas install standard)Latin9

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Et par eksemplerTekst filer

• Session WLatin1 • Session UTF-8data navne;

Infile "<TextFileANSI.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

data navne;

infile "<TextFileUTF8.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

data navne;

Infile "<TextFileANSI.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

data navne;

infile "<TextFileUTF8.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

INFILE WLatin1.sas

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Et par eksemplerTekst filer - Fixed

• Session WLatin1 • Session UTF-8data navne;

Infile "<TextFileANSI.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

data navne;

infile "<TextFileUTF8.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

run;

data navne;

infile "<TextFileANSI.txt>"

encoding='wlatin1';

length Navn $20;

input navn $;

KLNavn = Klength(navn);

LNavn = length(navn);

run;

data navne;

infile "<TextFileUTF8.txt>";

length Navn $20;

input navn $;

LNavn = length(navn);

KLNavn = Klength(navn);

run;

INFILE UTF-8.sas

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Et par eksemplerSAS Data

• Session WLatin1 • Session UTF-8data navne;

set fans.navne_wlatin;

LNavn = length(navn);

KLNavn = KLength(navn);

run;

data navne;

set fans.navne_utf8;

LNavn = length(navn);

KLNavn = KLength(navn);

run;

data navne;

set fans.navne_wlatin;

LNavn = length(navn);

KLNavn = KLength(navn);

run;

data navne;

set fans.navne_utf8;

LNavn = length(navn);

KLNavn = KLength(navn);

run;

SET WLatin1.sas

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Et par eksemplerSAS Data – pas på længder

• Session WLatin1 • Session UTF-8data frugt;

set fans.frugt_L1;

run;

data frugt;

set fans.frugt_u8;

run;

data frugt;

set fans.frugt_L1;

run;

data frugt;

set fans.frugt_u8;

run;

SET2 WLatin1.sas

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Et par eksemplerSAS Data – pas på længder – måske løsning

• Session WLatin1 • Session UTF-8data frugt;

set fans.frugt_L1;

run;

data frugt;

set fans.frugt_u8;

run;

/* CVP: Character Variable Padding */

/* Default CVPMULTIPLIER = 1,5 */

libname t cvp '<path>';

data frugt;

set t.frugt_L1;

run;

data frugt;

set fans.frugt_u8;

run;

SET2 UTF-8.sas

Copyright © SAS Inst itute Inc. A l l r ights reserved.

DBCS(MBCS) vs SBCS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

PAUSEVi begynder igen kl. 11:20

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Secure - hvad betyder det for din kode(sftp, https)Sara Armandi (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

– Hvad betyder det for din kode (SFTP, HTTPS)

Sara Armandi

SecureSara Armandi

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

HTTP

HTTPSFTP

SFTP

Encryption

Authorization

SSL

SSH

TLS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

HTTP Procedure: Using HTTPS

• In SAS 9.4M3, the FTP access method also supports Secure FTP (FTPS). FTPS includes full support for the Transport Layer Security (TLS) and Secure Socket Layer (SSL) cryptographic protocols, including the use of server-side public key authentication certificates and client-side authorization certificates.

• https://go.documentation.sas.com/?docsetId=lestmtsglobal&docsetTarget=p0v0ijxl1k6d4bn16cshtic7u4i3.htm&docsetVersion=9.4&locale=en#n0ypyegm0s59vln1wc9ghi3krygu

• Details

Copyright © SAS Inst itute Inc. A l l r ights reserved.

FILENAME Statement: FTP vs FTPS

• For both SAS 9.4 (beginning with SAS 9.4M3) and the full SAS Viya deployment, secure communication over HTTP (HTTPS) is provided globally by default.

• https://go.documentation.sas.com/?docsetId=proc&docsetTarget=p19qqqyq9te9u3n1oq8fbdta7dqt.htm&docsetVersion=9.4&locale=en

Copyright © SAS Inst itute Inc. A l l r ights reserved.

More Info

• https://blogs.sas.com/content/sgf/2013/11/20/how-to-use-encryption-in-base-sas-9-4/

• https://www.youtube.com/watch?v=EDvARXCu3VQ

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Excel til SASEksempler på Import, ODS, xlxs libname

Sara Armandi (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Agenda

• Import

• Peg-klik

• Kode

• Libname Engine

• Export

• Peg-klik

• Kode

• Libname Engine

• Rapporter ODS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Importer Excel – Enterprise GuidePeg-Klik

• File -> Import Data:

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Importer Excel – Enterprise GuideKode

• PROC IMPORT

• Datafile=

• Out=

• DBMS=

• REPLACE

• GETNAMES=YES

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Importer Excel – Enterprise GuideLibname Engine

• LIBNAME Engine:

• EXCEL

• XLSX

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Exporter til Excel – Enterprise GuidePeg-Klik

• Export Data:

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Exporter til Excel – Enterprise GuideKode

• PROC EXPORT

• Data=

• Outfile=

• DBMS=

• LABEL

• REPLACE

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Exporter til Excel – Enterprise GuideLibname Engine

• LIBNAME Engine:

• EXCEL

• XLSX

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Exporter til Excel – Enterprise GuideODS

• ODS EXCEL

• FILE=

• OPTIONS(

- Froozen_headers

- Sheet_name

- Autofilter

- …….

• Excel formatering

• Excel formler

Copyright © SAS Inst itute Inc. A l l r ights reserved.

AfslutningFrans Holm (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Netværksmødersas.com/fans -> Network Meetings

2020

- 4/3 Programmerings netværk – Aarhus

- 12/3 Visual Analytics netværk - København

- 13/3 Visual Analytics netværk – Aarhus

- 25/3 Webinar - SAS Data preparation & SAS studio Features and Functions

- 29/3 SAS Global Forum – Washington DC

- 23/4 Sådan anvender vi SAS – Aarhus

- 29/4 Webinar - Walkthrough of the Local SAS Forum programs. 2 divided tracks FI/SE

- 13/5 Webinar - Walkthrough of the Local SAS Forum programs. 2 divided tracks DK/NO

- 27/5 SAS Forum - København

- 17/6 Webinar - Version Control

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Hvordan anvender jeg SAS?5 min. oplæg…

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

SAS Global Forum 2020

• Events

• Welcome reception – Sunday afternoon

• Nordic dinner – Monday evening

• Knowledge Sharing

• Lunch – knowledge sharing

• Meeting with R&D

• Meet Ron Agresta – Director R&D Data Management

• Sightseeing

• Sunday: Arlington & National Mall

• Running: Saturday and Monday morning

Nordic Add-ons

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

• Support• https://support.sas.com

• Dokumentation• https://support.sas.com/en/documentation.html

• Youtube• https://www.youtube.com/user/SASsoftware

• https://www.youtube.com/sasusers (NYHED)

• Webinar – Nordisk vs. Globale• https://www.sas.com/sas/events/nordic/nordic-webinars.html

• https://www.sas.com/da_dk/webinars.html

• https://www.sas.com/en_us/learn/ask-the-expert-webinars.html

• Proceedings Global forum• https://www.sas.com/en_us/events/sas-global-forum/program/proceedings.html

• https://www.lexjansen.com/cgi-bin/xsl_transform.php?x=sgf2018

• SAS Nyhedsbreve• https://www.sas.com/da_dk/news/e-newsletters.html

• FANS• sas.com/fans

• https://www.sas.com/sas/events/nordic/fans-nordic-sas-user-group.html#

• LinkedIN• https://www.linkedin.com/learning/topics/sas

• Uddannelse• https://www.sas.com/da_dk/training/overview.html

Hvor kan du finde viden om

SAS software?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

LodtrækningVind en sas-ting

sas.com

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Tak for i dagvi ses fans

Husk evaluering

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Hvordan koder man i Viya?Frans Holm (SAS)

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Emner

• SAS beregningsmotorer/runtime environments

• 4 Rules to Understand CAS Management of In-Memory Data

• Lidt teori om CAS/CASLIB

• Programmering i CAS

• CAS

• CASLIB

• Proc CASUTIL

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Arkitektur overblik

Application Services (Microservices)

Runtime Environments

APIs /UIs

MVA CAS ESP In-DB

Data Access

Security, Governance, Administration

Host Environments

Products / SolutionsPython

RJavaLua

REST APIs

SAS codeSAS interfaces

Streaming

Cloud

Hadoop

Database

Customer IntelligenceRisk

Fraud & Security

AnalyticsVisualization

Data Management

On-Premises, Private, Public, Hybrid Cloud

...

Copyright © SAS Inst itute Inc. A l l r ights reserved.

SAS Viya

Servers

Programming run-time

Services

Infrastructure Servers

Analytic Engines

CAS

ESP

SPRE

Microservices

Web Applications

SAS Cache Locator

SAS Cache Server

SAS Configuration Server

Apache HTTP Server

SAS Infrastructure Data Server

SAS Message Broker

SAS Secret Manager

SAS Workspace

Server and SAS

Object Spawner

SAS/CONNECT

Server & Spawner

Embedded Web

Application Server

SAS Launcher

Server

SAS Compute

Server

MAS

ElasticSearch

Components & Services

69

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Analytic Engines

70

The Analytic Engines:

• CAS: Cloud Analytic Services

• SPRE: SAS Programming Runtime Environment

• ESP: Event Stream Processing

• MAS: Micro Analytic Scoring

• Elastic Search: OpenSource search and indexing

Analytic Engines

CAS

ESP

SPRE

MAS

ElasticSearch

Copyright © SAS Inst itute Inc. A l l r ights reserved.

SAS Launcher Server and Service

• The SAS Launcher Server is used to start processes in a SAS Viya environment - just as the SAS Object Spawner is used to start processes in SAS 9

• The SAS Launcher Service is a SAS Viya microservice that exposes a REST interface to - start processes using a launcher server

- define launcher contexts

Copyright © SAS Inst itute Inc. A l l r ights reserved.

SAS Compute Server and Service

• The SAS Compute Server is a back-end server process that provides access to SAS Foundation in a SAS Viya environment - just as a Workspace Server does with SAS 9

• The SAS Compute Service is a SAS Viya microservice that exposes a REST interface to - talk to a compute server

- define compute contexts

Copyright © SAS Inst itute Inc. A l l r ights reserved.

4 Rules to Understand CAS Management of In-Memory Data

• № 1. CAS analyzes data in SASHDAT format, regardless of the original source

• № 2. All in-memory data is memory mapped to a locally-accessible backing store

• № 3. The OS, not CAS, moves data to/from the backing store

• № 4. CAS_DISK_CACHE is where all replicated copies of data are stored

Copyright © SAS Inst itute Inc. A l l r ights reserved.

CAS/CASLIB

Copyright © SAS Inst itute Inc. A l l r ights reserved.

REST OF THE DISK

OS SWAP

Memory & CAS

• When CAS writes to memory, it actually writes to “buffer cache*” as opposed to writing to a dedicated memory space

• CAS data in memory is not static, data moves from disk in and out of memory as required

• This means CAS:

• Will never run out of memory

• Won't waste memory

• Could thrash if memory is tight

• Always has to have the data on "local" disk for reloading data blocks that are no longer in memory

CAS Disk CacheOr SASHDAT

RAM (buffer cache)

Disk

RAM (dedicated)Physical memory

*buffer cache=file cache=page cache

CAS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

CAS_DISK_CACHEDefault Use

• CAS_DISK_CACHE:

• Acts a part of CAS’ total memory space for working with data

• Enables flexibility to work with data over time as well as failure resilience

• Is used (or not) depending on many factors including: data provider, data format, encryption, programming directives, etc.

• Rule of thumb:

• If the original source is unencrypted SASHDAT which can be m-mapped by the Workers on locally accessible disk, then CAS_DISK_CACHE is not used as an in-memory backing store for that data load.

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Data MovementSerial transfer with data from a SAS runtime CAS client

CONTROLLER WORKER WORKER WORKER

cas1.site.com cas2.site.com cas3.site.com cas4.site.comviya1.site.com

Infrastructure services

SPRE

SAS Viya

A B C

CAS_DISK_CACHE

In memory (RAM)

CAS

A TableB C

Communication

Data transfer

C A B

Copyright © SAS Inst itute Inc. A l l r ights reserved.

In memory tables

Copyright © SAS Inst itute Inc. A l l r ights reserved.

CASLIB

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Programmering i Viya

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Programmering i Viya

• Intet nyt – du kan det samme

• Datastep & Proc’s

• Og alligevel …

• Regler:

• Data skal være i CAS for at kunne bruge CAS

• Ikke alt gøres på samme måde i CAS

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Kode

• CAS

• CASLIB

• Proc CASUTIL

• List

• Load

• Save

• Deletesource

• Contents

• Se: ”Viya_kode_eksempler.sas”

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Spørgsmål?????

• Hvorfor bliver et CASlib ikke allokeret til et Libname?

• Hvilke filer er på disk under CASUSER?

• Gemmer LOAD filerne?

• Loader SAVE tabellen i memory?

• Hvilke datasæt er tilgængelige på CASUSER in-memory?

• efter start af ny session?

• Hvilke datasæt kan jeg se i Visual Analytics?

• Hvor mange rækker er der i outputtet?

• Hvordan er outputtet sorteret?

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Viya tegning

Data

Data

CAS

ComputeServer

Visual Analytics

SASStudio

CAS_DISK_CACHECAS CAS_DISK_CACHECAS CAS_DISK_CACHE

Copyright © SAS Inst itute Inc. A l l r ights reserved.

Links

• https://support.sas.com//en/software/sas-viya.html

• https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.5&docsetId=pgmsashome&docsetTarget=home.htm&locale=en

• https://communities.sas.com/t5/SAS-Communities-Library/CAS-data-distribution-DUPLICATE-a-REPLICATION-using-COPIES-Can/ta-p/368796

top related