BookmarkSubscribeRSS Feed
Melody1027
Calcite | Level 5

Screenshot 2023-10-24 175621.png

In the data file Exe2_Data11.txt, the field indicates contains a street address and a person who lives at that address, age and gender. Create a SAS data set that contains one
observation for each person who lives at a specific address. The finished SAS data set
looks like this:

 

Exe2_Data11.txt

30 Daguilar St
Mary Chan,21,F
David Chan,25,M
Man Chan,2,M
15 Fuk Hi St
William Leung,30,M
20 San Fat St
Walter Ma,25,M
John Ma,50,M
78 Stanley St

 

4 REPLIES 4
PeterClemmensen
Tourmaline | Level 20

Is your desired output a SAS data set or a .txt file?

Melody1027
Calcite | Level 5
SAS data set
Kurt_Bremser
Super User
data want;
infile "path_to_your_file" dlm="," dsd truncover;
length
  address $100
  name $50
  age 8
  gender $1
;
retain address;
input @;
if countw(_infile_,",") > 1
then do;
  input name age gender;
  output;
end;
else input address $100.;
run;

SAS Innovate 2025: Register Now

Registration is now open for SAS Innovate 2025 , our biggest and most exciting global event of the year! Join us in Orlando, FL, May 6-9.
Sign up by Dec. 31 to get the 2024 rate of just $495.
Register now!

Mastering the WHERE Clause in PROC SQL

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.

Discussion stats
  • 4 replies
  • 852 views
  • 2 likes
  • 3 in conversation