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

hi,

i want to change this table that will make one variable with aebodsys as main category and aedecod as subcategories.

Jedrzej_0-1615927727223.png

like that

VAR
Cardiac disorder
atrial flutter
palpitations
Tachycardia
Cardiac failrue
 
Psychiatric disorders
Delirium
 
Gastrointestinal disorders
Constipation

 

data AE;
input USUBJID $ 1-3 AEBODSYS $ 5-30 AEDECOD $ 32-49 ;
datalines;
101 Cardiac disorders Atrial flutter
101 Gastrointestinal disorders Constipation
102 Cardiac disorders Cardiac failure
102 Psychiatric disorders Delirium
103 Cardiac disorders Palpitations
103 Cardiac disorders Palpitations
103 Cardiac disorders Tachycardia
run;

 

thank you for your help

1 ACCEPTED SOLUTION

Accepted Solutions
ballardw
Super User

Your data step does not create data similar to your picture. This does:

data AE;
   infile datalines dlm=',';
input USUBJID :$3. AEBODSYS :$30. AEDECOD :$20. ;
datalines;
101,Cardiac disorders,Atrial flutter
101,Gastrointestinal disorders,Constipation
102,Cardiac disorders,Cardiac failure
102,Psychiatric disorders,Delirium
103,Cardiac disorders,Palpitations
103,Cardiac disorders,Palpitations
103,Cardiac disorders,Tachycardia
run;

 

Your code was reading from fixed columns. If it worked before you pasted it to the forum you need to know that the main message windows reformat text and will remove repeated blanks and other forms of "white space". So it is best to place code in to a text box opened on the forum as above to keep formatting.

 

Data almost certainly should stay in the current form for any sort of analysis.

Can you describe how you intend to use that data with all the variable in one column?

 

If you need groups for analysis or reporting your data may already be as you need.

Example simple report:

Proc tabulate data=AE;
   Class  AEBODSYS  AEDECOD ;
   table  AEBODSYS * AEDECOD,
         n
   ;
run;

 

 

 

View solution in original post

1 REPLY 1
ballardw
Super User

Your data step does not create data similar to your picture. This does:

data AE;
   infile datalines dlm=',';
input USUBJID :$3. AEBODSYS :$30. AEDECOD :$20. ;
datalines;
101,Cardiac disorders,Atrial flutter
101,Gastrointestinal disorders,Constipation
102,Cardiac disorders,Cardiac failure
102,Psychiatric disorders,Delirium
103,Cardiac disorders,Palpitations
103,Cardiac disorders,Palpitations
103,Cardiac disorders,Tachycardia
run;

 

Your code was reading from fixed columns. If it worked before you pasted it to the forum you need to know that the main message windows reformat text and will remove repeated blanks and other forms of "white space". So it is best to place code in to a text box opened on the forum as above to keep formatting.

 

Data almost certainly should stay in the current form for any sort of analysis.

Can you describe how you intend to use that data with all the variable in one column?

 

If you need groups for analysis or reporting your data may already be as you need.

Example simple report:

Proc tabulate data=AE;
   Class  AEBODSYS  AEDECOD ;
   table  AEBODSYS * AEDECOD,
         n
   ;
run;

 

 

 

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!

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.

SAS Training: Just a Click Away

 Ready to level-up your skills? Choose your own adventure.

Browse our catalog!

Discussion stats
  • 1 reply
  • 496 views
  • 0 likes
  • 2 in conversation