0% found this document useful (0 votes)
2 views

HW1_code

The document contains SAS code for importing and processing data from CSV and text files. It includes steps for reading data about artists, US presidents, and pumpkins, with specific formatting and input options. The code also includes procedures to print the imported datasets for review.

Uploaded by

jzhao110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

HW1_code

The document contains SAS code for importing and processing data from CSV and text files. It includes steps for reading data about artists, US presidents, and pumpkins, with specific formatting and input options. The code also includes procedures to print the imported datasets for review.

Uploaded by

jzhao110
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

2/8/25, 7:02 PM Code: aggregate.

sas

/* Part1 */
LIBNAME MYREF '/home/u63991217/sasuser.v94';
PROC IMPORT
DATAFILE= "/home/u63991217/my_shared_file_links/haticesahinoglu0/DATA Files/Artists.csv"
OUT = MYREF.user_artist
DBMS="dlm";
DELIMITER =",";

run;

PROC CONTENTS DATA=MYREF.user_artist;


run;

PROC PRINT DATA=MYREF.user_artist;


run;

/* Part2 */
DATA PRESIDENTS;
Infile '/home/u63991217/my_shared_file_links/haticesahinoglu0/DATA Files/USpresident.txt' dlm=' ' DSD;

LENGTH president $ 10;


INPUT president $ party $ number;

/*
1. INPUT option
a. I have the president's name followed by a dollar sign because the name is a character.
I also specify in LENGTH that name should read 10 characters. This is because Washington is longer than the
default 8 character limit.

b. Party is follwed by a dollar sign because it is a character. 8 bytes will be fine be because it is either
R (republican) or D (democrat)

c. number, there is a number that I don't know what it signifies as the third column in the text file.
Since it is a number, not need for a trailing $

d. dlm = '' because there is space as a delimiter

e. DSD to ignore empty data columns


*/

PROC PRINT DATA = PRESIDENTS;


RUN;

/* Part3 */
DATA PUMPKINS;

INFILE '/home/u63991217/my_shared_file_links/haticesahinoglu0/DATA Files/Pumpkin.dat';


INPUT
name $ 1-16
num1 $17-19
category $ 20-21
Date $ 22-32
num2 33-36
num3 37-40
num4 41-44
;
PROC PRINT DATA = PUMPKINS;
RUN;

DATA PUMPKINS_MODIFIED;
INFILE '/home/u63991217/my_shared_file_links/haticesahinoglu0/DATA Files/Pumpkin.dat';
input name $16. +1 num1 2. +1 type $1. +1 date mmddyy10. +1 meas1
3.1 +1 meas2 3.1 meas3 3.1;

PROC PRINT DATA = PUMPKINS_MODIFIED;


RUN;

about:blank 1/2
2/8/25, 7:02 PM Code: aggregate.sas

about:blank 2/2

You might also like