BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
MaryA_Marion
Lapis Lazuli | Level 10

SAS STUDIO Release: 3.8 (Enterprise Edition)

Is there a description of what form dataset should be in for sgplot and other s series plots? I have the following:

proc sgplot data=profile;
series x=brand y=response / group=subject;
run;

I want a very simple profile plot of lifetime * brand for each subject connecting lines between brands for each subject.

Is there a clue in this code as to what input form to use?  I usually use longform. I am finding all sorts of graphs out there with code but coordinating the data set with the procedure is another matter.

DATA profile;
INPUT brand $ response;
subject=_n_;
DATALINES;
A  73
A  64
A  67 
B  81 
B  77
;

 

1 ACCEPTED SOLUTION

Accepted Solutions
MaryA_Marion
Lapis Lazuli | Level 10

Solution found. I was trying to enter subject numbers easily. They were not correct and all subsequent graphs were incorrect. I went back to the old technique of using scatter and series statements.

DATA profile;
INPUT subject brand $ response;
DATALINES;
1 A 73
2 A 64
3 A 67
1 B 81
2 B 77
;
proc sgplot data=profile;
scatter x=brand y=response / group=subject;
series x=brand y=response / group=subject;
run;

 

 

View solution in original post

3 REPLIES 3
sbxkoenk
SAS Super FREQ

Post moved by me to Graphics board (coming from Visual Analytics board).

Koen

sbxkoenk
SAS Super FREQ

Hello,

 

With series statement in proc sgplot an a unique subject (subject only occurring once) you do not see anything as there's no marker by default and there's nothing to connect.

 

I think you want something like the below :

DATA profile;
INPUT brand $ response subject $;
*subject=_n_;
DATALINES;
A  73 1
A  64 2
A  67 3
B  81 1
B  77 2
;
run;

proc sgplot data=profile;
series  x=brand y=response / group=subject;
scatter x=brand y=response / group=subject;
run;
/* end of program */

Koen

MaryA_Marion
Lapis Lazuli | Level 10

Solution found. I was trying to enter subject numbers easily. They were not correct and all subsequent graphs were incorrect. I went back to the old technique of using scatter and series statements.

DATA profile;
INPUT subject brand $ response;
DATALINES;
1 A 73
2 A 64
3 A 67
1 B 81
2 B 77
;
proc sgplot data=profile;
scatter x=brand y=response / group=subject;
series x=brand y=response / group=subject;
run;

 

 

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

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
  • 3 replies
  • 517 views
  • 0 likes
  • 2 in conversation