Pdf 3 25 2 000 a 13oct01 2 07 3 000 b 14dec45 4 33 5 000 d

Pdf File 93.21 KByte,

SAS Certification Handout #1: Ch. 1-3

/* SAS Certification Class Handout #1 SAS Code Base Programming Ch. 1-3

*/

/* LIBNAME and PROC CONTENTS */

/* define libref: "cert" refers to library of all SAS data files (.sas7bdat) in specific directory */

libname cert 'C:\jrstevens\Teaching\SAS_Cert\LIB';

/* Define data set a1 in cert library */

data cert.a1; input x y z $ date $; cards;

3.25 2

A 13Oct01

2.07 3

B 14Dec45

4.33 5

D 25Dec14

7.97 6.001 Z 1January12

7.33 .

. .

;

run;

proc print data=cert.a1; run;

The SAS System

Obs x y z date

1 3.25 2.000 A 13Oct01

2 2.07 3.000 B 14Dec45

3 4.33 5.000 D 25Dec14

4 7.97 6.001 Z 1January

5 7.33

.

proc print data=a1; run; /* Error: File WORK.A1.DATA does not exist. */

/* Check cert.a1 contents */ proc contents data=cert.a1; run;

The SAS System

The CONTENTS Procedure

Data Set Name

CERT.A1

Observations

5

Member Type

DATA

Variables

4

Engine

V9

Indexes

0

Created

01/07/2015 15:09:08

Observation Length 32

Last Modified

01/07/2015 15:09:08

Deleted Observations 0

Protection

Compressed

NO

Data Set Type

Sorted

NO

Label

Data Representation WINDOWS_64

Encoding

wlatin1 Western (Windows)

Engine/Host Dependent Information

Data Set Page Size

65536

Number of Data Set Pages 1

First Data Page

1

Max Obs per Page

2039

Obs in First Data Page

5

Number of Data Set Repairs 0

ExtendObsCounter

YES

Filename

C:\jrstevens\Teaching\SAS_Cert\LIB\a1.sas7bdat

Release Created

9.0401M0

Host Created

X64_7PRO

Alphabetic List of Variables and Attributes

# Variable

Type

Len

4 date

Char

8

1 x

Num

8

2 y

Num

8

3 z

Char

8

/* Intro to variable formats */

/* Define data set with specific variable widths */

data cert.a1; input x 2-5 y 7-11 z $ 13 date $ 15-26; cards;

3.25 2

A 13Oct01

2.07 3

B 14Dec45

4.33 5

D 25Dec14

7.97 6.001 Z 1January12

7.33 .

. .

;

proc print data=cert.a1;

run;

The SAS System

Obs x y z date

1 3.25 2.000 A 13Oct01

2 2.07 3.000 B 14Dec45

3 4.33 5.000 D 25Dec14

4 7.97 6.001 Z 1January12

5 7.33

.

/* Use informat, and include spaces in character variable */

data cert.a1;

informat x dollar5.2;

input x y z $ date $ 15-26; cards;

3.25 2

A 13Oct01

2.07 3

B 14Dec45

4.33 5

D 25Dec14

7.97 6.001 Z 1 January 12

7.33 .

. .

;

run;

proc print data=cert.a1;

run;

The SAS System

Obs x y z date

1 3.25 2.000 A 13Oct01

2 2.07 3.000 B 14Dec45

3 4.33 5.000 D 25Dec14

4 7.97 6.001 Z 1 January 12

5 7.33

.

proc contents data=cert.a1; run;

The CONTENTS Procedure

Data Set Name

CERT.A1

Observations

5

Member Type

DATA

Variables

4

Engine

V9

Indexes

0

Created

01/07/2015 15:12:13

Observation Length 40

Last Modified

01/07/2015 15:12:13

Deleted Observations 0

Protection

Compressed

NO

Data Set Type

Sorted

NO

Label

Data Representation WINDOWS_64

Encoding

wlatin1 Western (Windows)

Engine/Host Dependent Information

Data Set Page Size

65536

Number of Data Set Pages 1

First Data Page

1

Max Obs per Page

1632

Obs in First Data Page

5

Number of Data Set Repairs 0

ExtendObsCounter

YES

Filename

C:\jrstevens\Teaching\SAS_Cert\LIB\a1.sas7bdat

Release Created

9.0401M0

Host Created

X64_7PRO

Alphabetic List of Variables and Attributes

# Variable Type Len Informat

4 date

Char 12

1 x

Num

8 DOLLAR5.2

2 y

Num

8

3 z

Char

8

/* SPSS Engine and output options */

/* 1vote00.por is a portable SPSS datafile containing "about 230 socioeconomic and political variables for 1,800 respondents surveyed before and after the 2000 election"; reference */

/* Set SPSS engine */ libname temp spss "C:\jrstevens\Teaching\SAS_Cert\Notes\1vote00.por";

/* See all contents of temp library */ proc contents data=temp._all_ nods; run;

The SAS System

The CONTENTS Procedure

Directory

Libref

TEMP

Engine

SPSS

Physical Name C:\jrstevens\Teaching\SAS_Cert\Notes\1vote00.por

# Name Member Type 1 _FIRST_ DATA

/* See resulting data */ proc contents data=temp._first_; run;

Data Set Name Member Type Engine Created Last Modified Protection Data Set Type

The SAS System

The CONTENTS Procedure

TEMP._FIRST_ Observations

.

DATA

Variables

182

SPSS

Indexes

0

10/27/2002 16:50:55 Observation Length 1456

01/07/2015 15:14:18 Deleted Observations 0

Compressed

NO

Sorted

NO

Label

Data Representation Default

Encoding

Default

Engine/Host Dependent Information ORIGSOFT SPSS for MS WINDOWS Release 10.0 SPSSINFO (NONE) COMPRESS NO SPSSTYPE PORTFILE

Alphabetic List of Variables and Attributes

# Variable Type Len Format Label

119 ABORTION Num 8 8.

+Attitudes toward abortion

18 AGE

Num 8 8.

age recoded into 5 groups

40 AIDS_

Num 8 1.

L7c. INC/DEC SPENDING ON AIDS RESEARCH

36 BIBLE

Num 8 8.

+Feeling about the Bible

115 BIGGROUP Num 8 1.

+Q5. GOVT RUN BY BIG INTERSTS/BENEFIT ALL

31 BILLAPPR Num 8 1.

A12. APPROVE/DISAPPR CLINTON JOB

49 BLACKS_ Num 8 1. ...

L7p. INC/DEC AID TO BLACKS

13 WHENFIRM Num 8 2.

+C7. TIMING OF PRES VOTE DECISION

3 WILLVOTE Num 8 1.

P3. R EXPECT TO VOTE IN NOV ELECTION

130 WORK

Num 8 8.

+work for a party or candidate?

19 YEARSOLD Num 8 2.

RESPONDENT AGE in years

/* Create copy in WORK library */ data vote; set temp._first_; run;

/* Look at just first few rows using OPTIONS statement */ options firstobs=1 obs=5; proc print data=vote;

var Survey WillVote BushVote Age Discuss; run; options obs=max;

Download Pdf File
Related download
Related searches