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-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
  • 1 reply
  • 312 views
  • 0 likes
  • 2 in conversation