BookmarkSubscribeRSS Feed
saza
Quartz | Level 8

Was asked the following question:

1) Reshape the data from long to wide according to the Date variable
(i.e., creating multiple new variables based on Date). Retain ID, LastName, and DOB
on each line, and use the values in Event as the new variable names.

I thought I had it but when I use my code, nothing in the dataset seemed to change? There were still 100 rows like the original dataset

proc transpose data = covidlng.covidlong out = cohortwide prefix = Event;
by id lastname dob;
id event;
var date;
run;

saza_0-1645648703500.png

what I see when I hit run

saza_0-1645649985336.png

proc contents for OG dataset

saza_1-1645650016330.png

proc contents for the cohort wide

 

 

 

7 REPLIES 7
Reeza
Super User
Show the log and proc contents on each data set please.
saza
Quartz | Level 8
Sure, added them to the original post
Reeza
Super User
That's a proc print, not proc contents and for only one data set.

But your log shows that your output data set has 472 records not 100, are you sure you're checking the correct output data set?
saza
Quartz | Level 8
I am sorry for the confusion on my end. Hopefully my update helps
Reeza
Super User

Your log and code and everything looks correct. What makes you think it's wrong?

Reeza
Super User

I think SAS Studio only shows you the first 50 or 100 records by default, you need to press a button to see the rest of the records?

ballardw
Super User

What does your LOG look like? Copy the text from the log, open a text box on the forum using the </> icon above the message window and paste the text. Include the program statements and all the notes or messages from that code.

 

I ran your code on your data set and get 472 records in the output data set, which is the same as you show in the proc contents for the wide set. The original data set has 1416 observations. So I do not see where you are getting 100.

 

I suspect that perhaps you do not want to use PREFIX=EVENT has that makes the new variable names EVENT+the value of the event variable.

 

 

Ready to join fellow brilliant minds for the SAS Hackathon?

Build your skills. Make connections. Enjoy creative freedom. Maybe change the world. Registration is now open through August 30th. Visit the SAS Hackathon homepage.

Register today!
What is ANOVA?

ANOVA, or Analysis Of Variance, is used to compare the averages or means of two or more populations to better understand how they differ. Watch this tutorial for more.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 7 replies
  • 599 views
  • 2 likes
  • 3 in conversation