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

Don't miss out on SAS Innovate - Register now for the FREE Livestream!

Can't make it to Vegas? No problem! Watch our general sessions LIVE or on-demand starting April 17th. Hear from SAS execs, best-selling author Adam Grant, Hot Ones host Sean Evans, top tech journalist Kara Swisher, AI expert Cassie Kozyrkov, and the mind-blowing dance crew iLuminate! Plus, get access to over 20 breakout sessions.

 

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