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

Hi, on page 162 of the specialist prep guide, it states that ID statement will concatenate variables specified in that statement and indeed the print out shown in the book is concatenated.

 

Nietzsche_1-1667903783001.png

 

However I am unable to reproduced it with the same code, the variables are separated by a comma and space/line break. Why is there a difference in the output?

proc transpose data=cert.cltrials out=transtrials2;
var cholesterol triglyc uric;
id name testdate;
run;
proc print data=transtrials2;
run;

Nietzsche_2-1667904061303.png

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).
1 ACCEPTED SOLUTION

Accepted Solutions
Kurt_Bremser
Super User

The commas and additional letters are in your data in the name variable.

See this for an example:

data trials;
input name $ date :date9. value;
format date date9.;
datalines;
John,A 01jan1960 1
Richard 02jan1960 2
;

options validvarname=any;

proc transpose data=trials out=trials1;
var value;
id name date;
run;

proc print data=trials1;
run;

options validvarname=v7;

proc transpose data=trials out=trials2;
var value;
id name date;
run;

proc print data=trials2;
run;

The second run with validvarname=v7 is just there to show the effect of the option.

There may be a difference between the data used when the prep guide was set up and the data as it is now.

View solution in original post

3 REPLIES 3
andreas_lds
Jade | Level 19

Interesting. I don't have access to the data used, but when i run

proc transpose data=sashelp.class out=work.transposed;
   var Weight Height;
   id Name Age;
run;

the result is as expected, not comma between the values.

Kurt_Bremser
Super User

The commas and additional letters are in your data in the name variable.

See this for an example:

data trials;
input name $ date :date9. value;
format date date9.;
datalines;
John,A 01jan1960 1
Richard 02jan1960 2
;

options validvarname=any;

proc transpose data=trials out=trials1;
var value;
id name date;
run;

proc print data=trials1;
run;

options validvarname=v7;

proc transpose data=trials out=trials2;
var value;
id name date;
run;

proc print data=trials2;
run;

The second run with validvarname=v7 is just there to show the effect of the option.

There may be a difference between the data used when the prep guide was set up and the data as it is now.

Nietzsche
Lapis Lazuli | Level 10

Thanks Kurt.

 

You are correct, this solved the mystery. The data provided is not matching as I mentioned in the prep guide errata thread and it is causing all these confusion. 

Who is the editor/proof reader at SAS for these prep guides man? I swear I can do a better job.

 

Nietzsche_0-1667995846806.png

 

SAS Base Programming (2022 Dec), Preparing for SAS Advanced Programming (Cancelled).

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