Hi, I'd like to create a table like the following where the variable names/labels are in the first column and associated values are in the second column but I am having a hard time finding coding for this online or in the SAS guides. Any suggestions would be appeciated.
Name | Indiviual A's Name |
St Address | Indiviual A's St Address |
City | Indiviual A's City |
State | Indiviual A's State |
Zip Code | Indiviual A's Zip Code |
Phone Number | Indiviual A's Phone Number |
Indiviual A's Email |
Hi,
How about Proc transpose..
data have;
input name $ add $ city $ country $;
cards;
shiva ramnagar delhi india
;
run;
proc transpose data=have out=want;
VAR name add city country;
run;
Thanks,
Shiva
If you open a SAS dataset by double clicking on it in the SAS explorer window that will bring up the table using the viewtable program. Once it is open, if you click on view (from the menu bar) you can switch the view from table view to form view.
That may be what you are looking for.
Thanks, that's helpful but I need it as output to include in a report. I tried looking at options in proc print but didn't see anything that would display the data like the table above.
Hi,
How about Proc transpose..
data have;
input name $ add $ city $ country $;
cards;
shiva ramnagar delhi india
;
run;
proc transpose data=have out=want;
VAR name add city country;
run;
Thanks,
Shiva
Here is one possibility:
proc sql noprint;
select catx(" ","variable='",name,"';value=",name,";output;")
into :vars separated by " "
from dictionary.columns
where libname="SASHELP" and
memname="CLASS"
;
quit;
data want (keep=variable value);
length variable $32;
length value $32;
set sashelp.class;
&vars.;
run;
proc print data=want;
run;
Is that data example in a SAS data set? If so, please run proc contents on the data set and show the results.
If it is not in a SAS data set then the question is how to read the file and that can depend on a whole lot of factors such as file type.
One more thought in case the other suggestions don't meet your needs. Take a look at:
http://support.sas.com/documentation/cdl/en/lrcon/62955/HTML/default/viewer.htm#a002153702.htm
I wasn't even aware of it before you asked your question, but found it via a Google search.
proc fsbrowse data=SASHELP.CLASS label printall ;
run;
There used to be a PROC LABEL (or maybe it was PROC LABELS) intended for printing adhesive labels but also suitable for a task like this. I can't find it now.
: I 'm not aware of such a proc and can't find anything on it. Did you possibly mean proc forms?
see, e.g.: http://support.sas.com/kb/25/335.html
I agree with Art, I was remembering PROC FORMS. It will probably only work with LISTING, though. As I remember, you used it to do mailing labels and mounted the forms onto the printer. I think you could tell it how many pages of XXX's to print so the operators could align the label sheets.
Oh, my! What a blast from the past! Computer rooms, operators, line printers & pinfeed forms!
cynthia
Are you looking for something like the following?
What's your output destination?
DATA NULL;
FILE 'z:\DROPBOX\TEMP.TXT';
SET SASHELP.CLASS;
PUT "Name: " NAME;
PUT "AGE: " AGE;
PUT "WEIGHT: " WEIGHT;
RUN;
Art:
I was just so caught up in nostalgia for the old days of pinfeed label forms, I did neglect to mention PROC REPORT. But actually, if the need is NOT for Avery labels, but just for listing the variables in one or two columns -- since PROC REPORT needs a DATA step to manipulate the data, I'd probably just use FILE PRINT ODS within the DATA step program. Not sure whether I'd make a table template or not. But probably not.
Before I went down any of those roads -- PROC FORMS or DATA _NULL_ or PROC REPORT, I would be tempted to make a form in Word with merge fields defined, then I would make a simple CSV file with SAS and do the merge of the CSV file with the Word doc from within Word.
Of course, I'm still blissing out over PROC FORMS memories. That is a good paper, thanks for providing the link.
cynthia
Cynthia: Enjoy the memories. I'll try to bring up some new(old) ones next week so that the nostalgic period can continue. Hmmm .. proc explode, proc spell, proc hier, proc gwhiz, proc nickname, proc extract, proc kba and proc fscalc might be good candidates
SAS Innovate 2025 is scheduled for May 6-9 in Orlando, FL. Sign up to be first to learn about the agenda and registration!
Learn the difference between classical and Bayesian statistical approaches and see a few PROC examples to perform Bayesian analysis in this video.
Find more tutorials on the SAS Users YouTube channel.
Ready to level-up your skills? Choose your own adventure.