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

I tried to submit the code below, but SAS does't show the word after the blank in the values of the variable "COMPLICATION".

Can anyone fix it?

 

data complication;
length SUBJECT 8 COMPLICATION $15;
input SUBJECT COMPLICATION $ ;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

1 ACCEPTED SOLUTION

Accepted Solutions
brzcol
SAS Employee
data complication;
length Subject 8 Complication $15;
input Subject  Complication & $;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

What you need to do is add in the & modifier on the input statement since the values include spaces.

 

https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsref&docsetTarge...

View solution in original post

5 REPLIES 5
brzcol
SAS Employee
data complication;
length Subject 8 Complication $15;
input Subject  Complication & $;
datalines;
2076 Pneumonia
3585 DVT(Lower)
3630 DVT(Lower)
4585 Compartment
4599 Aspiration
4760 Acute Resp
4775 Pneumonia
2076 Heart Attack
3585 Pneumonia
3660 Heart Attack
4585 Pneumonia
4599 Pneumonia
4760 Pneumonia
4775 DVT(Lower)
2076 Renal Fail
3585 Renal Fail
3630 Pancreatit
4585 Skin Break
4599 Renal Fail
4760 Renal Fail
4775 Pneumonia
3630 Pneumonia
4775 Renal Fail
;
run;

What you need to do is add in the & modifier on the input statement since the values include spaces.

 

https://go.documentation.sas.com/?cdcId=pgmsascdc&cdcVersion=9.4_3.4&docsetId=lestmtsref&docsetTarge...

Shmuel
Garnet | Level 18

Alternatively to @brzcol solution you can try next code:

data complication;
infile datalines truncover;
length Subject 8 Complication $15;
input Subject  Complication $char15.;
datalines;
2076 Pneumonia
......
; run;
MrT13
Fluorite | Level 6

Thanks very much for your help.

I'm just wondering why do i need to specify the format in the input statement as well?

Reeza
Super User
You're aware the data you have posted is already truncated as well?
MrT13
Fluorite | Level 6
Yes, I do. But thanks for the interest.

sas-innovate-2024.png

Available on demand!

Missed SAS Innovate Las Vegas? Watch all the action for free! View the keynotes, general sessions and 22 breakouts on demand.

 

Register now!

How to Concatenate Values

Learn how use the CAT functions in SAS to join values from multiple variables into a single value.

Find more tutorials on the SAS Users YouTube channel.

Click image to register for webinarClick image to register for webinar

Classroom Training Available!

Select SAS Training centers are offering in-person courses. View upcoming courses for:

View all other training opportunities.

Discussion stats
  • 5 replies
  • 685 views
  • 2 likes
  • 4 in conversation