Download presentation
Presentation is loading. Please wait.
Published byMartha Stokes Modified over 8 years ago
1
SAS PROGRAMMING II COMBINING AND MANAGING SAS DATA SETS a. Multiple input data sets b. SAS special variables c. Collapsing techniques d. Reshaping SAS data sets e. Data library management
2
Review: array & do loop The following ARRAY statement lists the three variables ExamScore1, ExamScore2, and Paper: This statement tells SAS to – Make a group named SCORELIST for the duration of this DATA step. – Put three variable names in SCORELIST: ExamScore1, ExamScore2, and Paper. – From this point in the DATA step, one of these variables can be referenced by either its original name or its array reference. For example, the names ExamScore1 and SCORELIST{1} are equivalent. ARRAY scorelist {3} ExamScore1 ExamScore2 Paper; Group name# of memberList of member
3
Review: array & do loop Iterative DO loops are used to repeatedly execute the statements within a DO group, changing the value of the index-variable each time. The number of iterations and the value of the index variable are determined by the "start", "stop" and "increment“ parameters, or by the list of “values”. DO index-variable=start TO stop BY increment; DO index-variable=start TO stop; DO index-variable=value1, value2, … valuen;
4
Example For example, the following code to add the odd integers from 1 to 7, is equivalent to: X=0 ; DO I = 1 to 7 by 2; X = X + I; END; Condition EvaluationValue iAction I = 1; if (i > 7) then "leave loop" False1X=X+i;X=0+1; I = I + 2;False3X=X+i;X=1+3; I = I + 2;False5X=X+i;X=4+5; I = I + 2;False7X=X+i;X=9+7; I = I + 2;True9Stop X = 0;Initial value X.
5
Array & do loop: EXAMPLES 1) Data set ONE contains one record per subject. Each record contains three scores. 2) convert data TWO back to data ONE. DATA two; SET one; ARRAY s(3) score1-score3; DO i = 1 TO 3; score = s(i); OUTPUT; END; DROP score1-score3; RUN; DATA three; SET two; RETAIN score1-score3; ARRAY s{3} score1-score3; DO j=1 TO 3; if j=i then s{i}=score; END; if i=3 then output; DROP i j score; RUN;
6
Multiple Input Data Sets Data sets can be combined in various ways using the following SAS statements to specify the input data sets: – SET Reads observations from one or more SAS data sets. – MERGE Joins observations from multiple SAS data sets. – UPDATE Modifies an existing "master file" SAS data set with a "transaction file" SAS data set, creating a new "master file". These statements can be controlled by using the BY statement in the DATA step. When the BY statement is used, all the input data sets must contain the BY variables and must be sorted by the BY variables. Observations that have the same values of all BY variables are said to belong to the same BY group.
7
The SET Statement The SET statement names the SAS input data sets from which observations will be read. SYNTAX SET SASDS1 SASDS2....; where SASDS is a name of the form LIBRARY.DATASET or ‘path \ dataset’. By default SAS will concatenate all data sets in the order listed in the SET statement. All observations will be read from the first data set listed, then all observations will be read from the second data set listed, and so on.
8
The SET Statement When used with a BY statement, SAS will interleave observations from the data sets listed in the SET statement. The observations are selected based on the sort order determined by the BY variables. All input data sets must be sorted by the BY variables, and the resulting output data set will be sorted by the BY variables as well. Example DATA short tall; SET classlib.class; IF ht <60 then output short; IF ht >=60 then output tall; RUN;
9
Examples Concatenation/Stack Interleaving DATA work.both; SET work.short work.tall; RUN; PROC SORT DATA=short; BY name; PROC SORT DATA=tall; BY name; DATA bothsorted; SET short tall; BY name; RUN;
10
The MERGE Statement The MERGE statement joins observations from the input data sets into a single observation in the output data set. SYNTAX MERGE SASDS1 SASDS2....; Where SASDS...are data set names. 1) One-to-one merging is performed when no BY statement is used. The first observation in each data set is joined to all the other first observations, the second to the second, etc. – One-to-one merging should be performed with caution, especially when the data sets contain different numbers of observations.
11
The MERGE Statement 2) Match merging (with the BY statement) joins the observations only when the values of the BY variables match. – One-to-many match merging allows variable values to be spread or "splayed" across all observations with the same BY values. – Many-to-many match merging joins observations one to one within the BY group until one data set reaches the last observation within the current BY group. This observation is then splayed across the remaining observations in the BY group.
12
One-to-One Merge Equal Numbers of Observations – Combine the LIST and DEMO data sets to produce the NEWCLASS data set. DATA newclass; MERGE list demo; RUN;
13
One-to-One Merge Unequal Numbers of Observations – Join two data sets with unequal numbers of observations DATA newclass; MERGE list2 demo2; RUN;
14
Match Merging Join only those observations with the same values of the BY variables. Note that both input data sets are sorted by the BY variable. DATA newclass; MERGE list2 demo2; BY name; RUN;
15
One-to-One Match Merge Example #1: Put blood pressure and lipid data into one file. DATA all; MERGE sbp lipids; BY id; RUN;
16
One-to-One Match Merge Example #2 : Merge pre-randomization file with post- randomization file. Both files contain common variables other than the BY variables. Notice the resulting data set. DATA all; MERGE prerand postrand; BY id; RUN;
17
One-to-One Match Merge Example #2 – When two merged data sets have common variables other than the BY variables, in the new data set those common variables contain values from the right-most data set in the MERGE statement. – If you don’t want to lose any common variable values, use the strategy on the next page.
18
One-to-One Match Merge Example #3: Merge pre-randomization file with post- randomization file. Both files contain common variables other than the BY variables, and you don’t want to lose any variable values. Solution: Use the RENAME data set option. DATA all; MERGE prerand(RENAME=(HDL=HDL0 LDL=LDL0)) postrand(RENAME=(HDL=HDL1 LDL=LDL1)); BY id; RUN;
19
Notes: Rename When you use a RENAME statement, use the old variable names in the current DATA step. When you use RENAME as an option on an input data set (such as in a SET or MERGE statement), use the new variable names in the current DATA step. DATA all; MERGE prerand(RENAME=(HDL=HDL0 LDL=LDL0)) postrand(RENAME=(HDL=HDL1 LDL=LDL1)); BY id; HDLdiff = HDL1 - HDL0; LDLdiff = LDL1 - LDL0; RUN; DATA prerand; set prerand; BY id; rename HDL=HLD0; if HDL=999 then HDL=.; RUN; Old variable name in current data stepNew variable name in current data step
20
One-to-One Match Merge Example #4: Two BY Variables DATA all; MERGE sbp ldl; BY id visit; RUN;
21
One-to-Many Match Merging One data set in a MERGE statement may contain multiple observations with the same values of the BY variables within each BY group. MERGE joins the observation from the "one" data set with each observation in the "many" data set. In match merging, the program data vector is initialized to missing only at the beginning of a new BY group. This allows information from the "one" data set to be splayed across the corresponding BY group observations in the "many" data set.
22
One-to-Many Match Merge Example #1 DATA grades; MERGE list hw; BY name; RUN;
23
One-to-Many Match Merge Example #2: When the same variables are in more than one data set, the value of the variable from the last data set mentioned in the MERGE statement is used. DATA grades2; MERGE grades fixhw; BY name hwnum; RUN; Missing values in FIXHW overwrite values in GRADES.
24
One-to-Many Match Merge Example #3 DATA all; MERGE sbp demographics; BY id; RUN;
25
One-to-Many Match Merge Example 4 DATA all; MERGE sbp demographics; BY id; age = age*10; RUN; What’s wrong with AGE?
26
One-to-Many Match Merge Example #5: Merge the department-specific means onto each record. PROC MEANS DATA=classlib.sales NWAY; CLASS dept; VAR cost; OUTPUT OUT=out1 MEAN=MeanCost; RUN; DATA sales2; MERGE sales out1; BY dept; RUN;
27
One-to-Many Match Merge Example #6: Merge the overall mean onto each record. DATA new; SET classlib.class; IF _N_=1 THEN SET out1; DROP _TYPE_ _FREQ_; RUN; Why does this work??? Because variables read with a SET statement are automatically retained from one iteration of the DATA step to the next. PROC MEANS DATA=classlib.class NOPRINT; VAR wt; OUTPUT OUT=out1 MEAN=MeanWt; RUN; DATA new; merge classlib.class out1; DROP _TYPE_ _FREQ_; RUN; Why does this not work???
28
Many-to-Many Merge Example DATA all; MERGE sbp lipids; BY id; RUN; This is usually a situation you want to avoid!
29
The UPDATE Statement The UPDATE statement joins observations from two SAS data sets, an "old master file" data set and a "transaction file" data set. The resulting observations form a "new master file" data set. These observations contain the values of the variables in the old master file, except for those modifications specified in the transaction file. SYNTAX: UPDATE dat1 dat2; BY Variables; where – dat1 is the old master file; it must be sorted by the BY variables and must contain only one observation for each BY group and dat2 is the transaction file; it must be sorted by the BY variables, but may have multiple observations per BY group.
30
NOTES: the update statement Variables with non-missing values in the transaction file will replace those values in the PDV. Missing values will not replace values in the PDV. The PDV is initialized to missing only at the beginning of a new BY group. The PDV is output to the new master file only at the end of a BY group.
31
Update Example DATA grades2; UPDATE grades fixhw; BY name hwnum; RUN;
32
SAS Special Variables The following special variables can be created in DATA steps using SET, MERGE, or UPDATE statements. – The IN variable indicates whether the data set contributed to the current observation. – The END variable indicates that the current observation is the last to be processed. – FIRST.byvariable and LAST.byvariable indicate if the current observation is the first or last observation in the BY group. SYNTAX: SET MERGE dat1(IN=invari1) dat2(IN=invari2)...END=endvar; UPDATE
33
SAS Special Variables You control creation of the IN and END variables. The FIRST. and LAST. variables are created whenever your DATA step includes a BY statement, as follows. If a DATA step includes the BY statement BY var1 var2...; Then variables FIRST.var1, LAST.var1, FIRST.var2, LAST.var2... are automatically created. – The special variables exist in the PDV, but not in the output data sets. – The special variables are indicator variables with values of 0 (False) and 1 (True). – An IN variable can be created for each data set in a SET, MERGE, or UPDATE statement. – An END variable can be created for each SET, MERGE, or UPDATE statement.
34
Special Variables Example #1 DATA carsales; SET jan(IN=inJ) feb(IN=inF) END=eof; BY make; RUN; Jan Feb
35
Special Variables Example #2 Create a data set containing only observations where a match occurred on the BY variable. DATA matches; MERGE list2(IN=inlist) demo2(IN=indemo); BY name; IF inlist AND indemo; RUN;
36
One-to-One Match Merge Example Using IN Variables Merge pre-randomization and post-randomization data sets by ID. Only keep subjects who have a record in both files. Then create variables for the difference between pre-randomization and postrandomization values. DATA all; MERGE pre (IN=inpre RENAME=(hdl=HDL0 ldl=LDL0)) post(IN=inpost RENAME=(hdl=HDL1 ldl=LDL1)); BY id; IF (inpre=1) & (inpost=1); /* or IF inpre & inpost; */ HDLdiff = hdl1 - hdl0; LDLdiff = ldl1 - ldl0; RUN;
37
Another Match Merge Example Using IN Variables Merge SBP and LIPID data sets by ID and VISIT. Only keep ID / VISIT combinations with a record in both files DATA all; MERGE sbp(IN=ins) lipids(IN=inl); BY id visit; IF ins & inl; RUN;
38
A Closer Look at FIRST. and LAST. Say you have a data set of addresses sorted by State, City, and ZipCode, in that order. The following are all of the observations in four BY groups, along with their corresponding FIRST. And LAST. values. With the FIRST. and LAST. variables, you can detect four conditions: 1.Whether an observation is the first observation in a BY group. 2.Whether an observation is the last observation in a BY group. 3.Whether an observation is neither the first nor the last observation in a BY group. 4.Whether an observation is both the first and last (that is, the only) observation in a BY group.
39
A Closer Look at FIRST. and LAST.
40
Match Merge Example Using IN and FIRST.BY / LAST.BY Variables Merge SBP and LIPID data sets by ID and VISIT. Only keep subjects who have a record in both files, and only keep the first record for each subject. DATA all; MERGE sbp(IN=ins) lipids(IN=inl); BY id visit; IF (ins & inl) & first.id; RUN;
41
END Variable Example Find the # of girls and the # of students in the data set using the sum statement and END variable. DATA one; SET classlib.class END=eof; KEEP n f; n + 1; f + (sex='F'); IF (eof=1); RUN;
42
Example Transpose data set LIPIDS from multiple records per subject to one record per subject DATA two; SET lipids; BY id; RETAIN ldl1 ldl2 hdl1 hdl2; ARRAY vars{4} ldl1 ldl2 hdl1 hdl2; IF first.id THEN DO i = 1 to 4; vars{i} =.; end; IF visit=1 THEN DO; ldl1 = ldl; hdl1 = hdl; END; ELSE IF visit=2 THEN DO; ldl2 = ldl; hdl2 = hdl; END; KEEP id ldl1 ldl2 hdl1 hdl2; IF last.id THEN OUTPUT; RUN; PROC SORT DATA=lipids; BY id visit; RUN;
43
Collapsing Techniques Sometimes you will need to collapse a group of records to one record that represents the group and reflects some group quality: perhaps the number of records in the group, or whether a certain condition ever occurred in the group, or the minimum, maximum, sum, or mean of some variable in the group. In the following examples, ID is the grouping variable. In each initial data set, there are >=1 records per ID, but in each final data set, there is only one record per ID.
44
Examples a)Counting the number of records in the group PROC SORT DATA=initial; BY ID; RUN; DATA final; SET initial; BY ID; RETAIN count; IF first.ID THEN count=0; count = count + 1; IF last.ID THEN OUTPUT; KEEP ID count; RUN;
45
Examples b)Flagging whether a certain condition ever occurred in the group PROC SORT DATA=initial; BY ID; RUN; DATA final; SET initial; BY ID; RETAIN flag; IF first.ID THEN flag=0; IF THEN flag=1; IF last.ID THEN OUTPUT; KEEP ID flag; RUN;
46
Examples c)Finding the sum/minimum/maximum/mean of a variable within the group PROC SORT DATA=initial; BY ID; RUN; DATA final; SET initial; BY ID; RETAIN sum; IF first.ID THEN sum=0; sum = sum + x; IF last.ID THEN OUTPUT; KEEP ID sum; RUN; PROC MEANS DATA=initial NWAY; CLASS ID; VAR x; OUTPUT OUT=final SUM=sum; RUN;
47
Reshaping SAS data sets Long format – multiple observations per subject, one measurement in each observation, with variables identifying subject ID and observation number. – Required for analysis procedures. Wide format – one observation per subject, all measurements in one observation, with variables identifying subject ID, and observation number encoded in variable name. – Required for graphing procedures. Reshaping data from one to another – Data step: array, & do – PROC TRANSPOSE
48
Long to wide & vice versa Multiple record for each family. Variable year to identify the record. One record for each family. Multiple variables to identify the year. famidyearfaminc 19640000 19740500 19841000 29645000 29745400 29845800 39675000 39776000 39877000 famidfaminc96faminc97faminc98 1400004050041000 2450004540045800 3750007600077000
49
Long to wide: data step Which one you like most? data wide; set long; by famid; retain faminc96 - faminc98; array fam(*) faminc96 - faminc98; do i=1 to dim(fam); if i=year-95 then fam(i)=faminc; end; if last.famid; drop i faminc year; run; data wide; set long; retain faminc96 - faminc98; if year=96 then faminc96=faminc; else if year=97 then faminc97=faminc; else if year=98 then faminc98=faminc; if year=98 then output; drop faminc year; run; data wide; retain famid; array fam[*] faminc96-faminc98; do i=1 to dim(fam); set long; fam[i]=faminc; end; drop faminc i year; run;
50
Wide to long: data step data long; set wide; year=96; faminc= faminc96; output; year=97; faminc = faminc97; output; year=98; faminc = faminc98; output; drop faminc96- faminc98; run; data long; set wide; array fam(*) faminc96- faminc98; do i=1 to dim(fam); faminc=fam(i); year=95+i; output; end; drop faminc96- faminc98 i; run;
51
Examples Reshape the data set from one observation per pupil to one observation per test. DATA test; SET work.students; exam=1; grade=test1; OUTPUT; exam=2; grade=test2; OUTPUT; exam=3; grade=test3; OUTPUT; DROP test1-test3; RUN; DATA test; SET work.students; DROP test1-test3 i; ARRAY test{3} test1-test3; DO i = 1 TO 3; exam = i; grade = test{i}; OUTPUT; END; RUN;
52
PROC TRANSPOSE Syntax PROC TRANSPOSE ; BY var-list ; COPY variable(s); ID variable; IDLABEL variable; VAR variable(s); proc transpose data =long prefix=faminc out=wide (drop=_name_); var faminc; id year; by famid; run; proc transpose data = wide out = long(rename = (col1 =faminc)); var faminc96-faminc98; by famid; run;
53
PROC TRANSPOSE vs. DATA PROC TRANSPOSE uses a simpler program. The DATA step has more flexibility. – it can perform calculations at the same time it transposes the data. Or reshape involving multiple variables. proc transpose data=long5 out=wide5; by famid; id year; var faminc spend debt; run; data wide5; set long5; by famid; retain faminc96-faminc98 spend96- spend98 debt96-debt98; array fam[*] faminc96-faminc98; array spe[*] spend96-spend98; array deb[*] $3 debt96-debt98; do i=1 to dim(fam); if i=year-95 then fam[i]=faminc; if i=year-95 then spe[i]=spend; if i=year-95 then deb[i]=debt; end; if last.famid then output; drop faminc debt spend i year; run; This one does not give what you wanted. Numeric has been changed to character. You have to use proc transpose 3 times, and merge the results.
54
Multiple Output Data Sets A single DATA step can create more than one SAS data set using the more general forms of the DATA and OUTPUT statements: DATA SASDS1 SASDS2... SASDSN; OUTPUT SASDSX...; where – SASDS1... SASDSN are the names of the SAS data sets to be created in this step, and SASDSX is a subset of the N data set names listed in the DATA statement. – A DATA step may contain multiple OUTPUT statements. – Each OUTPUT statement may specify any combination of the SAS data sets listed in the DATA statement. – The current contents of the PDV are written to these data sets each time the OUTPUT statement is executed. – The statement OUTPUT; (without a list of data set names) writes the PDV to all data sets in the DATA statement. – A DATA step without an OUTPUT statement defaults to writing to all output data sets each time the bottom of the step is reached.
55
Examples A) Create SHORT and TALL data sets from CLASS in one DATA step DATA short tall; SET class; IF ht LT 60 THEN OUTPUT short; ELSE IF ht GE 60 THEN OUTPUT tall; RUN;
56
Examples B) Combining Multiple Input and Output Data Sets DATA tall boys all; MERGE list demo; BY name; IF ht >= 60 THEN OUTPUT tall; IF sex = 'M' THEN OUTPUT boys; OUTPUT all; RUN;
57
Examples C)Multiple Output Data Sets Containing Different Types of Information DATA one(DROP=n f) counts(KEEP=n f); SET classlib.class END=eof; RETAIN n f 0; n = n + 1; f = f + (sex='F'); IF (eof) THEN OUTPUT counts; OUTPUT one; RUN;
58
Multiple Output Data Sets Multiple output observations can be created from a single input observation by using several OUTPUT statements. The DROP and KEEP data set options can be used to control which variables are included or excluded from the PDV and the output data sets. The RENAME data set option can change the names of variables in the PDV and output data sets.
59
The DROP & KEEP Data Set Options The DROP and KEEP data set options can be used on each output data set named in the DATA statement to control which of the variables in the PDV get written to which output data sets. DATA list(KEEP=name sex) DEMO(DROP=sex age); SET classlib.class; RUN;
60
The DROP & KEEP Data Set Options They can also be used on the input data sets listed in SET, MERGE, and UPDATE statements to control which variables get read into the PDV. DATA both; MERGE class1(DROP=age) class2(DROP=sex); BY name; RUN;
61
The RENAME Data Set Option SYNTAX: SASDS(RENAME=(OLDNAME=NEWNAME...)) The RENAME option can be used on SET, MERGE and UPDATE statements to change the names of SAS variables between the input data sets and the PVD, and on the DATA statement to change names between the PDV and the output data sets. DATA combo; SET fall spring(RENAME=(test=exam)); RUN;
62
SAS Data Library Management A SAS data library may be permanent or temporary. Permanent libraries have a library name specified by the user, which must correspond to a LIBNAME statement. Temporary libraries have a library name of WORK. There are several SAS procedures that are useful in the management of SAS data libraries. PROC COPY can be used to copy all or some of the SAS data sets from one SAS data library to another. PROC DATASETS can be used to delete or modify data sets in a SAS data library. A single data set can be copied from one data library to another with a DATA step of the form DATA newlib.SASds; SET oldlib.SASds;
63
SAS Data Library Management Either of the above methods of copying data sets can be used to "back-up" data sets. "Backingup“ of a data set means making one or more copies of the data set and storing the copies in a safe place. One then has: – Backup copies stored safely away, and – A working copy used for calculations or other processing. – You can also back up SAS data sets by copying and pasting to different locations on your PC or workstation.
64
The COPY Procedure The COPY procedure can be used to copy some or all of the SAS data sets from one library to another. Syntax: PROC COPY IN=Libname OUT=Libname: Statements used with COPY: – SELECT list of data set names; – EXCLUDE list of data set names; If the output library contains a data set with the same name as a selected data set, it will be replaced. Operating system commands and operations (e.g. DOS COPY & PASTE) can also be used to copy SAS data sets. PROC COPY IN=classlib OUT=work; SELECT sales; RUN;
65
The DATASETS Procedure The DATASETS procedure is used to manage a SAS library. With PROC DATASETS you can list, copy, rename, and delete SAS data sets in a SAS data library. PROC DATASETS can alter the descriptor portion of SAS data sets. It can be used to rename variables and to change formats, informats, or labels. PROC DATASETS LIBRARY=libref ; DELETE mem_list ; /* delete files specified in mem_list */ CHANGE old_name=new_name ; /* rename SAS data set from old name to new */ COPY OUT=libref2 ; /* copy to another SAS library */ SELECT mem_list; CONTENTS DATA=sas_data_set ; /* get contents of a data set */ CONTENTS DATA=libref._ALL_ NODS; /* get contents of a SAS library */ MODIFY sas_data_set_ ; /* modify descriptor part of data set */ RENAME old_name=new_name ; /* rename a variable */ LABEL var='label' ; /* add or change variable label */ FORMAT var format; /* add, change, or delete a format */ QUIT;
66
PROC DATASETS Example LIBNAME soci 'e:\soci6200\sasdata'; PROC DATASETS LIBRARY= soci; DELETE hw3; CHANGE scores=test; CONTENTS DATA=class; COPY IN= soci OUT=work; SELECT class; MODIFY class; LABEL wt='Wt in Lbs.'; FORMAT ht 5.0; RENAME sex=gender; CONTENTS DATA=class; QUIT;
67
Transporting SAS Files Between Hosts The process of moving SAS files from one host environment to another is called TRANSPORTING. To move a SAS file from one host to another, you must convert the file to a format that can be recognized by the SAS System on other host systems. This format is called TRANSPORT format.
68
Transporting SAS Files Between Hosts The transport process includes: – exporting the SAS file (putting the file into transport format) – moving the transport file to another host environment via communications software such as FTP (use binary mode) – importing the transport file (restoring the file to the format appropriate to the receiving host). – Transport format is necessary when moving SAS files between machines running two different operating systems.
69
Transporting SAS Files Between Hosts If both the sending and the receiving host are running the same operating system, transport format is not necessary. Supposedly, Version 8 SAS data sets are in a format that is recognized by all operating systems. A transport file is a sequential file that contains one or more SAS data sets in SAS transport format. With the XPORT engine, a SAS data set in transport format can be used as input in a DATA step or processed by SAS procedures, including the COPY procedure. However, commonly the COPY procedure is used on the receiving host to restore the file to standard data set format rather than continually accessing the file with the XPORT engine.
70
Transporting with Release 6.06 or Later In release 6.06 or later the XPORT engine used in conjunction with PROC COPY can be used for creating or reading SAS data sets in transport format. The CPORT and CIMPORT procedures can also be used to transport SAS catalogs, data sets, and libraries. Use the CPORT and CIMPORT procedures to transport these items from one machine to another machine running under a different operating environment. Use communications software such as FTP to physically move the transport files.
71
Example Exporting a SAS Library / Data Set libname tran XPORT 'c:\soci6200\class.dat' ; libname sc 'c:\soci6200\sasdata' ; /* convert an entire library to transport format */ proc copy in=sc out=tran ; run; /* convert a single SAS data set to transport format */ proc copy in=sc out=tran ; select class ; run;
72
Example Importing a SAS Library / Data Set – The use of SAS’s XPORT format is very widespread. For example, pharmaceutical companies must use it as part of their drug submissions to the FDA. – So there is value in knowing how to turn a file that is in XPORT format into a SAS data set. libname tran XPORT 'c:\soci6200\class.dat' ; libname sc V8 'c:\soci6200\sasdata' ; /* import all files in a SAS transport file */ proc copy in=tran out=sc ; run; /* import a single file in a SAS transport file */ proc copy in=tran out=sc ; select class ; run;
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.