Statistical Wizards: Unleashing the Power of Data Analysis
How to import SPSS data files into SAS
proc import datafile='D:/Working Gorup/ [Link]'
out=data
dbms=spss
replace;
run;
[Link] Data: It imports data from the SPSS data file "[Link]" located at "D:/Working Group/".
[Link] Dataset: It saves the imported data into a SAS dataset named "data".
[Link] Option: The DBMS option specifies the type of database management system used to read the data file, which in this
case is SPSS.
[Link] Option: The REPLACE option indicates that if a dataset named "data" already exists, it should be replaced by the
newly imported data.
10/29/2024 Md. Akhtarul Islam 1
Statistical Wizards: Unleashing the Power of Data Analysis
How to import CSV data files into SAS
proc import datafile='D:/Working Group/[Link]'
out=data
dbms=csv
replace;
run;
[Link] import: This is a SAS procedure used to import data from external files into SAS datasets.
[Link]='D:/Working Group/[Link]': This specifies the path to the external data file to be imported. In this case, the file is named "[Link]" and is located in the
"D:/Working Group/" directory.
3. out=data: This specifies the name of the SAS dataset that will be created from the imported data. In this case, the dataset will be named "data".
4. dbms=spss: This specifies the type of file format of the external data file. SPSS format data files are often given the extension ".sav".
5. replace: This option indicates that if a dataset named "data" already exists in the SAS library, it should be replaced with the newly imported data.
6. run;: This statement indicates the end of the PROC IMPORT procedure and tells SAS to execute the procedure with the specified options.
10/29/2024 Md. Akhtarul Islam 2
Statistical Wizards: Unleashing the Power of Data Analysis
How to calculate age from birth and signing date
DATA data;
SET data;
age = INTCK('YEAR’, birth_date, signing_date);
RUN;
1. DATA data;: This line indicates the beginning of a data step where a dataset named "data" is being created or modified.
2. SET data;: This line reads an existing dataset named "data" to work with its observations.
3. age = INTCK('YEAR', birth_date, signing_date);: This line calculates the age of each individual by using the INTCK function, which calculates the number of
intervals between two dates. In this case, the interval is specified as 'YEAR', and the dates used are the individual's birth date and signing date. The result is stored
in a new variable called "age".
4. RUN;: This line indicates the end of the data step.
10/29/2024 Md. Akhtarul Islam 3
Statistical Wizards: Unleashing the Power of Data Analysis
SAS code utilizes the PROC FREQ procedure to generate frequency
tables
proc freq data = data ;
table gender wealth media ;
run;
1. PROC FREQ: This begins the PROC FREQ procedure, which is used for frequency analysis.
2. data = data: Specifies the dataset named "data" that contains the variables of interest.
3. table gender wealth media;: Specifies the variables for which frequency tables should be generated. In this case, it's gender, wealth, and media.
4. run;: This line indicates the end of the PROC FREQ procedure.
10/29/2024 Md. Akhtarul Islam 4
Statistical Wizards: Unleashing the Power of Data Analysis
How to import CSV data files into SAS
proc import datafile='D:/Working Group/[Link]'
out=data
dbms=csv
replace;
run;
[Link] import: This is a SAS procedure used to import data from external files into SAS datasets.
[Link]='D:/Working Group/[Link]': This specifies the path to the external data file to be imported. In this case, the file is named "[Link]" and is located in the
"D:/Working Group/" directory.
3. out=data: This specifies the name of the SAS dataset that will be created from the imported data. In this case, the dataset will be named "data".
4. dbms=spss: This specifies the type of file format of the external data file. SPSS format data files are often given the extension ".sav".
5. replace: This option indicates that if a dataset named "data" already exists in the SAS library, it should be replaced with the newly imported data.
6. run;: This statement indicates the end of the PROC IMPORT procedure and tells SAS to execute the procedure with the specified options.
10/29/2024 Md. Akhtarul Islam 5
Statistical Wizards: Unleashing the Power of Data Analysis
How to import CSV data files into SAS
proc import datafile='D:/Working Group/[Link]'
out=data
dbms=csv
replace;
run;
[Link] import: This is a SAS procedure used to import data from external files into SAS datasets.
[Link]='D:/Working Group/[Link]': This specifies the path to the external data file to be imported. In this case, the file is named "[Link]" and is located in the
"D:/Working Group/" directory.
3. out=data: This specifies the name of the SAS dataset that will be created from the imported data. In this case, the dataset will be named "data".
4. dbms=spss: This specifies the type of file format of the external data file. SPSS format data files are often given the extension ".sav".
5. replace: This option indicates that if a dataset named "data" already exists in the SAS library, it should be replaced with the newly imported data.
6. run;: This statement indicates the end of the PROC IMPORT procedure and tells SAS to execute the procedure with the specified options.
10/29/2024 Md. Akhtarul Islam 6
Statistical Wizards: Unleashing the Power of Data Analysis
How to import CSV data files into SAS
proc import datafile='D:/Working Group/[Link]'
out=data
dbms=csv
replace;
run;
[Link] import: This is a SAS procedure used to import data from external files into SAS datasets.
[Link]='D:/Working Group/[Link]': This specifies the path to the external data file to be imported. In this case, the file is named "[Link]" and is located in the
"D:/Working Group/" directory.
3. out=data: This specifies the name of the SAS dataset that will be created from the imported data. In this case, the dataset will be named "data".
4. dbms=spss: This specifies the type of file format of the external data file. SPSS format data files are often given the extension ".sav".
5. replace: This option indicates that if a dataset named "data" already exists in the SAS library, it should be replaced with the newly imported data.
6. run;: This statement indicates the end of the PROC IMPORT procedure and tells SAS to execute the procedure with the specified options.
10/29/2024 Md. Akhtarul Islam 7