BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Nilesh1603
Fluorite | Level 6

Data project.treatment_details;
input patient_id 1-5
treatment_type $6-25
start_date mmddyy10.
end_date mmddyy10.
response $26-35;
datalines;
00001 Chemotherapy 01/01/2023 03/31/2023 Partial Response
00002 Immunotherapy 02/15/2023 05/15/2023 Complete Response
00003 Targeted Therapy 03/01/2023 06/30/2023 Stable Disease
00004 Chemotherapy 04/10/2023 07/10/2023 Progressive Disease
00005 Immunotherapy 05/20/2023 08/20/2023 Partial Response
00006 Chemotherapy 06/01/2023 09/30/2023 Complete Response
00007 Targeted Therapy 07/15/2023 10/15/2023 Stable Disease
00008 Chemotherapy 08/10/2023 11/10/2023 Progressive Disease
00009 Immunotherapy 09/20/2023 12/20/2023 Partial Response
00010 Targeted Therapy 10/01/2023 01/31/2024 Complete Response
;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
PaigeMiller
Diamond | Level 26

Because your raw data is not aligned in columns, you need to use "Modified List Input" with the : and & modifiers. Please read about the meaning of & and : in this case

https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm#p1wk2...

 

Also, you need two consecutive blanks after the treatment_type, which indicates that SAS will allow one blank in treatment_type but when it comes to two consecutive blanks, it stops reading treatment_type and starts reading the next variable.

 

Data treatment_details;
input patient_id 1-5
treatment_type & :$20.
start_date :mmddyy10.
end_date :mmddyy10.
response & :$20.;
datalines;
00001 Chemotherapy  01/01/2023 03/31/2023 Partial Response
00002 Immunotherapy  02/15/2023 05/15/2023 Complete Response
00003 Targeted Therapy  03/01/2023 06/30/2023 Stable Disease
00004 Chemotherapy  04/10/2023 07/10/2023 Progressive Disease
00005 Immunotherapy  05/20/2023 08/20/2023 Partial Response
00006 Chemotherapy  06/01/2023 09/30/2023 Complete Response
00007 Targeted Therapy  07/15/2023 10/15/2023 Stable Disease
00008 Chemotherapy  08/10/2023 11/10/2023 Progressive Disease
00009 Immunotherapy  09/20/2023 12/20/2023 Partial Response
00010 Targeted Therapy  10/01/2023 01/31/2024 Complete Response
;
--
Paige Miller

View solution in original post

2 REPLIES 2
PaigeMiller
Diamond | Level 26

Because your raw data is not aligned in columns, you need to use "Modified List Input" with the : and & modifiers. Please read about the meaning of & and : in this case

https://documentation.sas.com/doc/en/pgmmvacdc/9.4/lestmtsref/n0lrz3gb7m9e4rn137op544ddg0v.htm#p1wk2...

 

Also, you need two consecutive blanks after the treatment_type, which indicates that SAS will allow one blank in treatment_type but when it comes to two consecutive blanks, it stops reading treatment_type and starts reading the next variable.

 

Data treatment_details;
input patient_id 1-5
treatment_type & :$20.
start_date :mmddyy10.
end_date :mmddyy10.
response & :$20.;
datalines;
00001 Chemotherapy  01/01/2023 03/31/2023 Partial Response
00002 Immunotherapy  02/15/2023 05/15/2023 Complete Response
00003 Targeted Therapy  03/01/2023 06/30/2023 Stable Disease
00004 Chemotherapy  04/10/2023 07/10/2023 Progressive Disease
00005 Immunotherapy  05/20/2023 08/20/2023 Partial Response
00006 Chemotherapy  06/01/2023 09/30/2023 Complete Response
00007 Targeted Therapy  07/15/2023 10/15/2023 Stable Disease
00008 Chemotherapy  08/10/2023 11/10/2023 Progressive Disease
00009 Immunotherapy  09/20/2023 12/20/2023 Partial Response
00010 Targeted Therapy  10/01/2023 01/31/2024 Complete Response
;
--
Paige Miller
Nilesh1603
Fluorite | Level 6
Thank you so so much @Paige Miller

sas-innovate-wordmark-2025-midnight.png

Register Today!

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.


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
  • 2 replies
  • 682 views
  • 0 likes
  • 2 in conversation