BookmarkSubscribeRSS Feed
☑ This topic is solved. Need further help from the community? Please sign in and ask a new question.
Tom
Super User Tom
Super User

@tarheel13 wrote:

I think this is already resolved as the link I posted explained the problem with SAS studio. I got the data step to work correctly already. 


Ok.  The link from SAS is a little confused.  It says the way to deal with the tabs in the data lines is to modify your code to use TAB as the delimiter instead of space.  That might work for this example where all of the spaces between the fields were actually tab characters, but will fail for most other cases where the tabs have replaced only some of the spaces between the fields.  If you did need to deal with tabs in the datalines then use the EXPANDTABS option of the INFILE statement instead of the suggestion in that post to modify the delimiter used to scan the datalines.

 

The best solution is to NOT put tabs into the file to begin with. If you set the option to convert tabs into spaces then when you paste the text with tabs you don't end up with tabs in the file. 

 

And if the original posted had used that option then the file they pasted into their question would not have had tabs either.

 

Plus you get the added advantage of not having tabs inserted into the program code either.  Tabs in program code are just an opportunity for creating extremely confusing looking code.

 

 

Tom
Super User Tom
Super User

Check the documentation

https://documentation.sas.com/doc/en/pgmsascdc/9.4_3.5/grstatproc/n1jkqnmk6y6ms9n1b2vvubyzqd4a.htm

Note: The SERIES statement plots data in data order. For this reason, the input data set should be sorted by the X variable. Otherwise, unexpected results might occur.
Merdock
Quartz | Level 8

Sorry, I forgot to mention but my dataset dat2 is sorted by visit so I'm not sure why those visits for ID#011 are not showing up in the order they're supposed to. I couldn't find anything concrete in the documentation about how to get the x-axis to display all 4 visits for all participants though, or if there might be any better plot/way to visualize change in status over time by ID

ballardw
Super User

What values do you expect to display for the ones that you did not provide???

 

 

Tom
Super User Tom
Super User

Fill in the holes in your series and then plot that version of the data.

proc sql ;
  create table skeleton as
  select * 
  from (select distinct id from dat) a
     , (select distinct visit from dat) b
  ;
quit;
data dat2;
  merge skeleton dat;
  by id visit;
run;


proc sgpanel data=dat2;
  panelby id/ uniscale=row;
  series x=visit y=status / markers
    markerattrs=(size=10pt);
run;

 

tarheel13
Rhodochrosite | Level 12

I tested @Tom 's code and it worked for me. @Merdock accept @Tom 's post as solution if it creates your desired results. 

Merdock
Quartz | Level 8
@tarheel13, thank you, it works for me as well. Accepted it as the solution!
Merdock
Quartz | Level 8
Thank you so much, Tom, this works perfectly!

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!
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
  • 22 replies
  • 1276 views
  • 8 likes
  • 4 in conversation