BookmarkSubscribeRSS Feed
🔒 This topic is solved and locked. Need further help from the community? Please sign in and ask a new question.
gx2144
Calcite | Level 5
That does not work.
ballardw
Super User

I am wondering why you think you need a macro in the first place.

You would likely be much better of by making the labels permanent in the data or providing one label statement in the proc freq code.

One of the unfortunate things with working with macro code is that some types of logic errors can cause problems such as making following code not run because something is unstable and if you likely have to restart your SAS session to do almost anything. Save code before closing down though.

Variable lists make calling multiple variables in a tables statement easy.

When code misbehaves it is a good idea to copy the code submitted along with all notes, warnings and errors for the bit that misbehaves and show us that in a code box opened on the forum with the </> icon to preserve formatting of any diagnostics.

 

proc freq data = quad.category1 order = freq;
tables q13 q15-q21 q27-q30 q33 q36
   q39 q46-q50 q52 q54 q55 q57-q63 
   q65-q70 q109;
/ missing nocum ;
label
q13='Compared to before COVID-19= your alcohol intake has'
q15='Before COVID-19= how often did you eat out (at a restaurant ?'
q16='Before COVID-19= how often did you order take-out/delivery?'
q17='Before COVID-19= how often did you cook at home?' 
q18='In the past week= how often have you eaten out?' 
q19='In the past week= how often have you ordered take-out/delivery' 
q20='In the past week= how often have you cooked at home?'
q21='In the past week= how has stress impacted your appetite?' 
q27='Has there been a change in your anxiety levels compared to before COVID-19?' 
q28='In the past week= you have felt joyful= cheerful= or optimistic' 
q29='In the past week= you have felt anxious= irritable= or tense' 
q30='In the past week= you have felt depressed= hopeless= or trapped' 
q33='Are you worried you will get sick with Coronavirus?' 
q36='Are you worried that a loved one will get sick with the Coronavirus?' 
q39='What is your sex?' 
q46='What is your age?' 
q47='In what type of community did you live before COVID-19?' 
q48='In what type of community do you live right now= during COVID-19?' 
q49='What is your total household income?' 
q50='What country do you reside in now?' 
q52='What state do you reside in right now?' 
q54='How long have these measures (shelter/stay in place= quarantine/isolation= curfew= social distancing been in place?' 
q55='Are you following these measures?' 
q57='Which of the following best describes your living situation before COVID-19?' 
q58='Which of the following best describes your living situation right now= during COVID-19?' 
q59='How many individuals currently (and temporarily live in your current place of residence= including yourself?' 
q60='How many children under the age of 18 live in your current place of residence?' 
q61='How many people over the age of 65 live in your current place of residence?' 
q62='Which of the following best describes your current relationship status?' 
q63='Which of the following categories best describes your employment status right now?' 
q65='Are you working remotely?' 
q66='How often have you gone outside in the past week?' 
q67='Before COVID-19= I exercised?' 
q68='During the COVID-19 pandemic= I exercise' 
q69='Compared to before COVID-19= I have?' 
q70='What is the highest level of education you have completed?' 
q109='What is the highest level of education you have completed?' 
;

Loading the same data set multiple times like this is very inefficient.

And are you sure the labels for Q70 and Q109 are correct?

gx2144
Calcite | Level 5
You are right. There is no need to use the macro here.

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
  • 17 replies
  • 1034 views
  • 0 likes
  • 6 in conversation