i have a list of data, how can i input to capture properly?
data test;
input title $ 1-26 year type $;
datalines;
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Juliet 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
;
run;
Hi and welcome to the SAS Community 🙂
Here is one way
data test;
input title $ 1-26 year type $;
datalines;
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Juliet 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
;
Hi " draycut", how did you able to paste the data in a nicely and structured way?
Earlier, I pasted the data would become like below unstructured way:-
Can please enlighten me?
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Juliet 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
To get your posts to look better make sure to use the Insert Code or Insert SAS Code button on the forum editor. That will put the proper HTML tags around the characters to prevent them from being interpreted as just normal paragraphs that should be reflowed to fit the display window.
There are three methods to read textual data
Hi @User_Help Good question to refresh my basics. Thank you for that
data test;
length Title $26;
input @;
Title=substr(_infile_,1,anydigit(_infile_)-1);
input @(anydigit(_infile_)) year 4. Type :$8.;
datalines;
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Juliet 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
;
run;
You don't "make it", you ask the sender to give you data in a usable format. Only if you export data, it's up to you to do that in a proper way:
data test;
input title $ 1-26 year type $;
datalines;
A Midsummer Night's Dream 1595 comedy
Comedy of Errors 1590 comedy
Hamlet 1600 tragedy
Macbeth 1606 tragedy
Richard III 1594 history
Romeo and Juliet 1596 tragedy
Taming of the Shrew 1593 comedy
Tempest 1611 romance
;
filename out temp;
data _null_;
set test;
file out;
put
title $26.
" "
year z4.
" "
type $8.
;
run;
/* this step is only there to show you the created datafile */
data _null_;
infile out;
input;
put _infile_;
run;
filename out clear;
Log excerpt:
64 data _null_; 65 infile out; 66 input; 67 put _infile_; 68 run; NOTE: The infile OUT is: (sensitive data redacted) Zuletzt geändert=10. Oktober 2019 15.14 Uhr, Dateigröße (Byte)=328 A Midsummer Night's Dream 1595 comedy Comedy of Errors 1590 comedy Hamlet 1600 tragedy Macbeth 1606 tragedy Richard III 1594 history Romeo and Juliet 1596 tragedy Taming of the Shrew 1593 comedy Tempest 1611 romance NOTE: 8 records were read from the infile OUT. The minimum record length was 40. The maximum record length was 40. NOTE: DATA statement used (Total process time): real time 0.00 seconds cpu time 0.01 seconds
Join us for SAS Innovate 2025, our biggest and most exciting global event of the year, in Orlando, FL, from May 6-9. Sign up by March 14 for just $795.
SAS' Charu Shankar shares her PROC SQL expertise by showing you how to master the WHERE clause using real winter weather data.
Find more tutorials on the SAS Users YouTube channel.